What the macro recorder actually records

The Excel macro recorder translates your mouse and keyboard actions into VBA code. I could probably write several pages describing how this is done, but the best way to show you is by example. Follow these steps:

1. Start with a blank workbook.

2. Make sure that the Excel window is not maximized. You don't want it to fill the entire screen.

3. Press Alt+F11 to activate the VBE window.

Note Make sure that this window is not maximized. Otherwise, you won't be able to see the VBE window and Excel's window at the same time.

4. Resize and arrange Excel's window and the VBE window so both are visible. (For best results, minimize any other applications that are running.)

5. Activate Excel, choose Developer Code Record Macro and then click OK to start the macro recorder.

6. Activate the VBE window.

7. In the Project Explorer window, double-click Modulel to display that module in the code window.

8. Close the Project Explorer window in the VBE to maximize the view of the code window.

Your screen layout should look something like the example in Figure 7-12. The size of the windows depends on your video resolution.

Figure 7-12: A convenient window arrangement for watching the macro recorder do its thing.

Now move around in the worksheet and select various Excel commands. Watch while the code is generated in the window that displays the VBA module. Select cells, enter data, format cells, use the Ribbon commands, create a chart, manipulate graphic objects, and so on. I guarantee that you'll be enlightened while you watch the code being spit out before your very eyes.

0 0

Post a comment