Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and

Similar presentations


Presentation on theme: "Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and"— Presentation transcript:

1 Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and
Visual Basic By Robert T. Grauer Maryann Barber Exploring Microsoft Office Exploring Excel Chapter 7 1

2 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Objectives (1 of 2) Define a macro Record and run a macro, view and edit a simple macro Use the InputBox statement Use a keyboard shortcut, and/or custom toolbar to execute a macro Exploring Microsoft Office Exploring Excel Chapter 7

3 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Objectives (2 of 2) Describe function of Personal Macro workbook Use the Step Into command to execute a macro one statement at a time Use Copy and Paste to duplicate an existing macro Use Visual Basic IF and DO statements to make decisions Exploring Microsoft Office Exploring Excel Chapter 7

4 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Overview Use macros to avoid repetitious tasks Macro is a set of instructions for Excel Macro instructions are written in the Visual Basic Programming Language Use the macro recorder to create macros Create more powerful macros Exploring Microsoft Office Exploring Excel Chapter 7

5 Introduction to Macros
Macro recorder stores Excel commands Macros are written in Visual Basic Macros can be displayed with Visual Basic Editor Use Project Explorer to locate macro modules Statements appear in Code window Exploring Microsoft Office Exploring Excel Chapter 7

6 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Macro Statements A Macro always begins and ends with Sub statement; End Sub statement Comments begin with apostrophe (‘) Range selects the starting or active cell or cells in Excel To perform multiple actions on the same object use With statement; End With Statement Exploring Microsoft Office Exploring Excel Chapter 7

7 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
A Macro Project Explorer upper left; Visual Basic on right Exploring Microsoft Office Exploring Excel Chapter 7

8 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Hands-On Exercise 1 Create a Macro Record the Macro Test the Macro Start the Visual Basic Editor Simplify the Macro Create the Erase Macro Shortcut Keys Edit the Macro Step through the Macro Print the Module Exploring Microsoft Office Exploring Excel Chapter 7

9 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Record Macro Exploring Microsoft Office Exploring Excel Chapter 7

10 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Testing the Macro Exploring Microsoft Office Exploring Excel Chapter 7

11 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Cell References Relative versus Absolute references Make sure to specify cell references Absolute cell address are constant; Relative cell address change Visual Basic uses Offset to indicate space from active cell Exploring Microsoft Office Exploring Excel Chapter 7

12 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Cell References Relative references ActiveCell.Offset(1,0).Range(“A1).Select Relative reference above means the cell one row below the active cell Absolute references Range(“A1”).Select Exploring Microsoft Office Exploring Excel Chapter 7

13 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Hands-On Exercise 2 Record Relative References Record the Macro The Personal workbook Edit the Macro Test the Revised Macro Add a Custom Tool Button Test the Custom Button Exit Excel Exploring Microsoft Office Exploring Excel Chapter 7

14 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Hands-On Exercise 3 Data Management Functions The Create Name Command The Go To Command Record the Macro Record the Macro (Edit Clear Command Record the Macro (Advanced Filter Command) View the Macro Assign the Macro Test the Macro Exploring Microsoft Office Exploring Excel Chapter 7

15 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Hands-On Exercise 4 Enable Macros Copy the Chicago Macro Create the Manager Macro Run the Manager Macro Assign a Button Test the Buttons Create the Chicago Manager Macro Change Button Properties Print the Workbook Exploring Microsoft Office Exploring Excel Chapter 7

16 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Other Macro Features Statements are color coded Visual Basic toolbar has seven buttons Customize the Visual Basic toolbar Step Into Command helps you debug a macro Opening a file with a macro will prompt a question about viruses Exploring Microsoft Office Exploring Excel Chapter 7

17 Loops and Decision Making
Including IF and Do statements allows for testing IF statement tests a condition and provides a positive and negative DO statement repeats a block of statements until a condition becomes true Exploring Microsoft Office Exploring Excel Chapter 7

18 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Hands-On Exercise 5 The ClearColor Macro Record the Highlight Manager Macro View the Macro Test the Macro Add the IF Statement An Endless Loop Complete the Macro Exploring Microsoft Office Exploring Excel Chapter 7

19 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Summary (1 of 2) A macro automates a repetitive task. Macros are written in Visual Basic programming language Generic macros should be stored in the Personal Macro workbook Exploring Microsoft Office Exploring Excel Chapter 7

20 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Summary (2 of 2) Macros are run with a toolbar, keystroke or a button. Comments contain reminders to the programmer. More powerful Excel macros can be programmed with IF and DO Visual Basic statements Exploring Microsoft Office Exploring Excel Chapter 7

21 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Practice with Excel Finished Employee List Finished Advanced Macro workbook Corporate Totals The Power of Macros Exploring Microsoft Office Exploring Excel Chapter 7

22 Exploring Microsoft Office 2000 - Exploring Excel Chapter 7
Case Studies Spreadsheet Solutions Microsoft Word Starting Up Dade County Metro Zoo Antivirus Programs Exploring Microsoft Office Exploring Excel Chapter 7


Download ppt "Exploring Excel Chapter 7 Automating Repetitive Tasks: Macros and"

Similar presentations


Ads by Google