SlideShare a Scribd company logo
1 of 14
MACROS
CS1100 Computer Science and its Applications
CS1100 1
What is an Excel Macro?
• A macro is a set of instructions that tells Excel
to perform one or more actions
• An Excel macro is like a computer program but
it runs completely within Excel.
• Used to automate tedious or frequently
repeated tasks
– Macro can carry out sequence of actions much
more quickly
Macro Advantages
• Save time – even if you are an expert Excel
user, the computer can beat you every time
• Reduce errors – if the instructions are correct,
programs do not make mistakes
• Enforce standards – for example, each sales
rep may be required to submit a weekly
summary spreadsheet that follows a specific
structure and format
Macros
• Two ways to create a macro:
– Record it using the Macro Recorder
– Build by typing instructions in a VBA (Visual Basic
for Applications) module (beyond the scope of this
course)
– These two approaches can be combined
Macro Security
• Macro code can be used for evil too
• VBA macros included in Microsoft Office
documents (usually attached in emails) have
contained viruses in the past
– macro programs embedded in documents can be run
automatically when the document is opened, a
mechanism which can spread viruses.
• To configure security settings:
– File  Options  Excel Options  Trust Center
Trust Center Settings
Macro Viruses
• One famous macro virus called Melissa, released
in March, 1999:
– The virus sent a file called “List.doc” which it claimed
had passwords to 80 adult websites.
– Anyone who opened the document would get a free
copy of the Melissa macro virus.
– Melissa would then gather the first fifty entries in the
address book, and email itself to all of them.
– Melissa infected so many systems that by March 26th,
it was shutting down mail servers with all of the
infected emails traveling across the net.
Adding the Developer Tab
• Click on the File tab of the ribbon to open the File menu
• Click on Options to open the Excel Options dialog box.
• Click on the Customize Ribbon option in the left hand
window
• Under the Main Tabs section of the options window,
check off the Developer option.
• Click OK the Developer tab should now be visible
Workbook Formats
• The Excel default workbook format (.xlsx) does
not support macros
• To save a workbook containing macros, you
need to use one of the following formats:
– .xlsm
– .xlsb
– .xls
The Macro Recorder
• The recorder allows you to create macros
without knowing VBA
• Best to plan your macro before starting the
recorder
• If you’re curious about VBA and want to learn
to do more with macros, the recorder can be a
great learning tool
– You can examine the code that the recorder
generates and edit it.
The Macro Recorder dialog box
• 4 options to complete in this dialog box:
– Macro name - give your macro a descriptive
name. The name must begin with a letter and
have no spaces. Only letters, numbers and
underscore permitted.
– Shortcut key - (optional) fill in a letter, number,
or other character in the available space. This
will allow you to run the macro by holding down
the CTRL key and pressing the chosen letter on
the keyboard.
– Store macro in:
• This workbook: the macro is available only in this
file.
• New workbook: this option opens a new Excel file
and the macro is only available in the new file.
• Personal macro workbook: this creates a hidden file
Personal.xls which stores your macros and makes
them available in all Excel files
– Description: (optional) enter a description of
the macro
Macro Example
• Create a macro that automates the formatting
for a heading for the Atlantic Music Company:
Editing/Step Into a Macro
• An Excel macro is written in the Visual Basic
for Applications (VBA) programming language.
• Clicking on either the Edit or Step Into buttons
in the Macro dialog box starts the VBA editor
• Using the VBA editor and covering the VBA
programming language is beyond the scope of
this class.
Recording with Relative References
• By default a macro is recorded with absolute
references.
– If you are in Cell A1 when you record a macro, the
action will play back in A1
• To record with relative references,
click Use Relative References
• Now the macro plays
back in the selected cell.
Macro Example
• Let’s create a macro that automates the
format for a monthly sales summary:

More Related Content

Similar to ExcelMacros.pptx

Microsoft excel lessons FINAL GRADE 8 edited and final one.pptx
Microsoft excel lessons FINAL GRADE 8 edited and final one.pptxMicrosoft excel lessons FINAL GRADE 8 edited and final one.pptx
Microsoft excel lessons FINAL GRADE 8 edited and final one.pptx
JoshuaCasas7
 
Recordingandrunningmacrosintheofficeapplication3
Recordingandrunningmacrosintheofficeapplication3Recordingandrunningmacrosintheofficeapplication3
Recordingandrunningmacrosintheofficeapplication3
Astrid yolanda
 
Excel Basic_Incomplete_Guide_2020
Excel Basic_Incomplete_Guide_2020 Excel Basic_Incomplete_Guide_2020
Excel Basic_Incomplete_Guide_2020
Malasy45
 
Module 3 comp 312 - computer fundamentals and programming
Module 3   comp 312 - computer fundamentals and programmingModule 3   comp 312 - computer fundamentals and programming
Module 3 comp 312 - computer fundamentals and programming
diosdadamendoza
 

Similar to ExcelMacros.pptx (20)

Microsoft excel lessons FINAL GRADE 8 edited and final one.pptx
Microsoft excel lessons FINAL GRADE 8 edited and final one.pptxMicrosoft excel lessons FINAL GRADE 8 edited and final one.pptx
Microsoft excel lessons FINAL GRADE 8 edited and final one.pptx
 
Microsoft Excel - Macros
Microsoft Excel - MacrosMicrosoft Excel - Macros
Microsoft Excel - Macros
 
Recording and running macros in the office application
Recording and running macros in the office applicationRecording and running macros in the office application
Recording and running macros in the office application
 
Recordingandrunningmacrosintheofficeapplication3
Recordingandrunningmacrosintheofficeapplication3Recordingandrunningmacrosintheofficeapplication3
Recordingandrunningmacrosintheofficeapplication3
 
Getting started with CATIA V5 Macros
Getting started with CATIA V5 MacrosGetting started with CATIA V5 Macros
Getting started with CATIA V5 Macros
 
Learn about excel
Learn about excelLearn about excel
Learn about excel
 
Using macros in microsoft excel part 2
Using macros in microsoft excel   part 2Using macros in microsoft excel   part 2
Using macros in microsoft excel part 2
 
TFI Leverage Excel 2007 (QAT) 011310
TFI Leverage Excel 2007 (QAT) 011310TFI Leverage Excel 2007 (QAT) 011310
TFI Leverage Excel 2007 (QAT) 011310
 
Microsoft Excel Tutorial
Microsoft Excel TutorialMicrosoft Excel Tutorial
Microsoft Excel Tutorial
 
Microsoft Excel Basics
Microsoft Excel BasicsMicrosoft Excel Basics
Microsoft Excel Basics
 
An introduction to vba and macros
An introduction to vba and macrosAn introduction to vba and macros
An introduction to vba and macros
 
Vba 2 (students copy)
Vba 2 (students copy)Vba 2 (students copy)
Vba 2 (students copy)
 
Excel Basic_Incomplete_Guide_2020
Excel Basic_Incomplete_Guide_2020 Excel Basic_Incomplete_Guide_2020
Excel Basic_Incomplete_Guide_2020
 
Module 3 comp 312 - computer fundamentals and programming
Module 3   comp 312 - computer fundamentals and programmingModule 3   comp 312 - computer fundamentals and programming
Module 3 comp 312 - computer fundamentals and programming
 
How to create macro with example
How to create macro with exampleHow to create macro with example
How to create macro with example
 
Online Advance Excel & VBA Training in India
 Online Advance Excel & VBA Training in India Online Advance Excel & VBA Training in India
Online Advance Excel & VBA Training in India
 
Working with Excel Macros
Working with Excel MacrosWorking with Excel Macros
Working with Excel Macros
 
Using macros.pptx
Using macros.pptxUsing macros.pptx
Using macros.pptx
 
Excel 2007 Unit I
Excel 2007 Unit IExcel 2007 Unit I
Excel 2007 Unit I
 
XMetaL Macros for Non-Programmers
XMetaL Macros for Non-ProgrammersXMetaL Macros for Non-Programmers
XMetaL Macros for Non-Programmers
 

Recently uploaded

Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
zifhagzkk
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Bertram Ludäscher
 
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
wsppdmt
 
Abortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Jeddah |+966572737505 | get cytotecAbortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Klinik kandungan
 
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
LuisMiguelPaz5
 
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
mikehavy0
 
Abortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted Kit
Abortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted KitAbortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted Kit
Abortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted Kit
Abortion pills in Riyadh +966572737505 get cytotec
 

Recently uploaded (20)

Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?Case Study 4 Where the cry of rebellion happen?
Case Study 4 Where the cry of rebellion happen?
 
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
 
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
 
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...Reconciling Conflicting Data Curation Actions:  Transparency Through Argument...
Reconciling Conflicting Data Curation Actions: Transparency Through Argument...
 
Introduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptxIntroduction to Statistics Presentation.pptx
Introduction to Statistics Presentation.pptx
 
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATIONCapstone in Interprofessional Informatic  // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
 
Bios of leading Astrologers & Researchers
Bios of leading Astrologers & ResearchersBios of leading Astrologers & Researchers
Bios of leading Astrologers & Researchers
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
Harnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptxHarnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptx
 
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
如何办理澳洲拉筹伯大学毕业证(LaTrobe毕业证书)成绩单原件一模一样
 
Abortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Jeddah |+966572737505 | get cytotecAbortion pills in Jeddah |+966572737505 | get cytotec
Abortion pills in Jeddah |+966572737505 | get cytotec
 
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
 
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
Las implicancias del memorándum de entendimiento entre Codelco y SQM según la...
 
Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024Northern New England Tableau User Group (TUG) May 2024
Northern New England Tableau User Group (TUG) May 2024
 
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarjSCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
SCI8-Q4-MOD11.pdfwrwujrrjfaajerjrajrrarj
 
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
 
Pentesting_AI and security challenges of AI
Pentesting_AI and security challenges of AIPentesting_AI and security challenges of AI
Pentesting_AI and security challenges of AI
 
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
Abortion Clinic in Kempton Park +27791653574 WhatsApp Abortion Clinic Service...
 
Abortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted Kit
Abortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted KitAbortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted Kit
Abortion pills in Riyadh Saudi Arabia| +966572737505 | Get Cytotec, Unwanted Kit
 

ExcelMacros.pptx

  • 1. MACROS CS1100 Computer Science and its Applications CS1100 1
  • 2. What is an Excel Macro? • A macro is a set of instructions that tells Excel to perform one or more actions • An Excel macro is like a computer program but it runs completely within Excel. • Used to automate tedious or frequently repeated tasks – Macro can carry out sequence of actions much more quickly
  • 3. Macro Advantages • Save time – even if you are an expert Excel user, the computer can beat you every time • Reduce errors – if the instructions are correct, programs do not make mistakes • Enforce standards – for example, each sales rep may be required to submit a weekly summary spreadsheet that follows a specific structure and format
  • 4. Macros • Two ways to create a macro: – Record it using the Macro Recorder – Build by typing instructions in a VBA (Visual Basic for Applications) module (beyond the scope of this course) – These two approaches can be combined
  • 5. Macro Security • Macro code can be used for evil too • VBA macros included in Microsoft Office documents (usually attached in emails) have contained viruses in the past – macro programs embedded in documents can be run automatically when the document is opened, a mechanism which can spread viruses. • To configure security settings: – File  Options  Excel Options  Trust Center Trust Center Settings
  • 6. Macro Viruses • One famous macro virus called Melissa, released in March, 1999: – The virus sent a file called “List.doc” which it claimed had passwords to 80 adult websites. – Anyone who opened the document would get a free copy of the Melissa macro virus. – Melissa would then gather the first fifty entries in the address book, and email itself to all of them. – Melissa infected so many systems that by March 26th, it was shutting down mail servers with all of the infected emails traveling across the net.
  • 7. Adding the Developer Tab • Click on the File tab of the ribbon to open the File menu • Click on Options to open the Excel Options dialog box. • Click on the Customize Ribbon option in the left hand window • Under the Main Tabs section of the options window, check off the Developer option. • Click OK the Developer tab should now be visible
  • 8. Workbook Formats • The Excel default workbook format (.xlsx) does not support macros • To save a workbook containing macros, you need to use one of the following formats: – .xlsm – .xlsb – .xls
  • 9. The Macro Recorder • The recorder allows you to create macros without knowing VBA • Best to plan your macro before starting the recorder • If you’re curious about VBA and want to learn to do more with macros, the recorder can be a great learning tool – You can examine the code that the recorder generates and edit it.
  • 10. The Macro Recorder dialog box • 4 options to complete in this dialog box: – Macro name - give your macro a descriptive name. The name must begin with a letter and have no spaces. Only letters, numbers and underscore permitted. – Shortcut key - (optional) fill in a letter, number, or other character in the available space. This will allow you to run the macro by holding down the CTRL key and pressing the chosen letter on the keyboard. – Store macro in: • This workbook: the macro is available only in this file. • New workbook: this option opens a new Excel file and the macro is only available in the new file. • Personal macro workbook: this creates a hidden file Personal.xls which stores your macros and makes them available in all Excel files – Description: (optional) enter a description of the macro
  • 11. Macro Example • Create a macro that automates the formatting for a heading for the Atlantic Music Company:
  • 12. Editing/Step Into a Macro • An Excel macro is written in the Visual Basic for Applications (VBA) programming language. • Clicking on either the Edit or Step Into buttons in the Macro dialog box starts the VBA editor • Using the VBA editor and covering the VBA programming language is beyond the scope of this class.
  • 13. Recording with Relative References • By default a macro is recorded with absolute references. – If you are in Cell A1 when you record a macro, the action will play back in A1 • To record with relative references, click Use Relative References • Now the macro plays back in the selected cell.
  • 14. Macro Example • Let’s create a macro that automates the format for a monthly sales summary: