What Gets Recorded

When you turn on the macro recorder, Excel converts your mouse and keyboard actions into valid VBA code. I could probably write several pages describing how Excel does this, but the best way to understand the process is by watching the macro recorder in action. (Figure 6-1 shows how my screen looked while I had the macro recorder turned on.)

Follow these steps:

1. Start with a blank workbook.

2. Make sure that the Excel window is not maximized.

3. Press Alt+F11 to activate the VBE (and make sure that this program window is not maximized).

4. Resize and arrange the Excel window and the VBE window so that both are visible.

For best results, position the Excel window on top of the VBE window, and minimize any other applications that are running.

5. Activate Excel and choose ToolsOMacroORecord New Macro.

6. Click OK to start the macro recorder.

Excel inserts a new module (named Modulel) and starts recording in that module.

7. Activate the VBE program window.

8. In the Project Explorer window, double-click Module1 to display that module in the Code window.

Now play around for a while: Choose various Excel commands and watch the code being generated in the VBE window. Select cells, enter data, format cells, use the menus and toolbars, create a chart, manipulate graphics objects, and so on — go crazy! I guarantee that you'll be enlightened as you watch Excel spit out the VBA code before your very eyes.

Figure 6-1:

convenient window arrangement for watching the macro recorder do its thing.

Figure 6-1:

convenient window arrangement for watching the macro recorder do its thing.

0 0

Post a comment