Excel Macro Recorder Tutorial
Excel 2007 Macro Recorder Tutorial
� Ted FrenchFor more Excel tips and tricks go to my static page: Excel Tutorials and Tricks Series.
Excel Macro Recorder Tutorial
Note: For help on these steps, refer to the image above.
Related article: Excel 2003 Macro Tutorial
This tutorial covers using the macro recorder to create a simple macro in Excel. The macro recorder works by recording all keystrokes and clicks of the mouse.
The macro created in this tutorial will apply a number of formatting options to a worksheet titles.
In Excel 2007, all macro - related commands are located on the Developer tab of the ribbon. Often, this tab needs to be added to the ribbon in order to access the macro commands.
Adding the Developer Tab
Adding the Developer Tab
Note: For help on these steps, refer to the image above.
- Click on the Office button to open the drop down menu.
- Click on the Excel Options button located at the bottom of the menu to open the Excel Options dialog box.
- Click on the Popular option at the top of the left hand window of the open dialog box.
- Click on the Show Developer Tab in the ribbon in the right hand window of the open dialog box.
- Click OK.
- The Developer tab should now be visible in the ribbon.
Adding a Worksheet Title / The Excel Macro Recorder
Adding a Worksheet Title
Note: For help on these steps, refer to the image above.
Before we start recording our macro, we need to add the worksheet title we will be formatting.
Since the title of each worksheet is usually unique to that worksheet, we don't want to include the title in the macro. Therefore we will add it to the worksheet, before starting the macro recorder.
- Click on cell A1 in the worksheet.
- Type the title: Cookie Shop Expenses for June 2008.
- Press the Enter key on the keyboard.
Excel Macro Recorder
The easiest way to create a macro in Excel is to use the macro recorder. To do so:- Click on the Developers tab.
- Click on Record Macro in the ribbon to open the Record Macro dialog box.
The Macro Recorder Options
The Macro Recorder dialog box
Note: For help on these steps, refer to the image above.
There are 4 options to complete in this dialog box:
- Macro name - give your macro a descriptive name. The name must begin
with a letter and spaces are not allowed. Only letters, numbers and the
underscore character are 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
- Options:
- This workbook
- The macro is available only in this file.
- New workbook
- This option opens a new Excel file. The macro is available only in this new file.
- Personal macro workbook.
- This option creates a hidden file Personal.xls which stores your macros and makes them available to you in all Excel files.
- This workbook
- Description - (optional) enter a description of the macro.
- Set the options in the Record Macro dialog box to match those in the image above.
- Do Not click OK - yet - see below.
- Clicking the OK button in the Record Macro dialog box starts recording the macro you have just identified.
- As previously mentioned, the macro recorder works by recording all keystrokes and clicks of the mouse.
- Creating the format_titles macro involves clicking on a number of format options on the home tab of the ribbon with the mouse while the macro recorder is running.
- Clicking the OK button in the Record Macro dialog box starts recording the macro you have just identified.
- Go to the next step before starting the macro recorder.
Adding the Macro Steps
Recording the Macro
Note: For help on these steps, refer to the image above.
- Click the OK button in the Record Macro dialog box to start the macro recorder.
- Click on the Home tab of the ribbon.
- Drag select cells A1 to F1 in the worksheet to highlight them.
- Click on the Merge and Center icon to center the title between cells A1 and F1.
- Click on the Fill Color icon (looks like a paint can) to open the fill color drop down list.
- Choose Blue, Accent 1 from the list to turn the background color of the selected cells to blue.
- Click on the Font Color icon (it is a large letter "A") to open the font color drop down list.
- Choose White from the list to turn the text in the selected cells to white.
- Click on the Font Size icon (above the paint can icon) to open the font size drop down list.
- Choose 16 from the list to change the size the text in the selected cells to 16 point.
- Click on the Developer tab of the ribbon.
- Click the Stop Recording button on the ribbon to stop the macro recording.
- At this point, your worksheet title should resemble the title in the image above.
Running the Macro
Running a Macro in Excel
Note: For help on these steps, refer to the image above.
To run a macro you have recorded:
- Click on the Sheet2 tab at the bottom of the spreadsheet.
- Click on cell A1 in the worksheet.
- Type the title: Cookie Shop Expenses for July 2008.
- Press the Enter key on the keyboard.
- Click on the Developer tab of the ribbon.
- Click the Macros button on the ribbon to bring up the View Macro dialog box.
- Click on the format_titles macro in the Macro name window.
- Click the Run button.
- The steps of the macro should run automatically and apply the same formatting steps applied to the title on sheet 1.
- At this point, the title on worksheet 2 should resemble the title on worksheet 1.
Macro Errors / Editing a Macro
Macro Errors
Note: For help on these steps, refer to the image above.
If your macro did not perform as expected, the easiest, and best option is to follow the steps of the tutorial again and re - record the macro.
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 (see the image above).
Using the VBA editor and covering the VBA programming language is beyond the scope of this tutorial.
No comments:
Post a Comment