Microsoft Office Tutorials and References
In Depth Information
Using the Macro Recorder
Figure 15-3: A default column chart created from the data in A1:A7
1. Activate the chart.
2. Select Tools
Macro
Record New Macro. This displays the Record Macro
dialog box.
3. In the Record Macro dialog box, enter a name for the macro (no spaces
allowed). For this example, enter FormatChart as the Macro name and
choose This Workbook as the location for the macro.
4. Click OK to begin recording the macro. From this point, all your actions
will be converted to VBA code. Also, notice the small floating toolbar that
contains a blue square (the Stop Recording button). You can move this
toolbar out of the way, but don’t close it.
5. Change the Plot Area color to white.
6. Change the column color to red.
7. Change the gridlines to gray dashed lines.
8. Delete the legend.
9. Click the Stop Recording button in the floating toolbar. Or, choose
Tools
Macro
Stop Recording.
Your workbook will now contain a VBA module with a macro named
FormatChart . To view the macro, press Alt+F11 and double-click the workbook
name in the Project window. Double-click the Modules node to display the Module
(it will be named Module1). Figure 15-4 shows the macro that I recorded. Yours may
look a bit different, depending on how you performed the formatting steps. For
example, if you select the legend and press Del, the generated code will be different
than if you deleted the legend by clicking the Legend button in the Chart toolbar.
Search JabSto ::




Custom Search