Microsoft Office Tutorials and References
In Depth Information
Cleaning up recorded macros
Figure 15-4: A recorded macro
If you use the Formatting dialog boxes to record this macro, you’ll find that
Excel records quite a bit of extraneous code. Recording toolbar button clicks
often produces more efficient code.
To try out the macro, create another chart using the same data or different data.
Activate the chart and press Alt+F8 to display the Macro dialog box. Select the
FormatChart macro and click Run. All the formatting changes will be applied in an
instant.
For other ways to execute macros, refer to “Executing Macros,” later in this
chapter.
Cleaning up recorded macros
As you become more fluent with VBA, you’ll realize that the macros generated by
the macro recorder almost always need some additional work. For example, the
macro may include extraneous commands, which you can delete, and you may
want to add some error-checking code.
ELIMINATING SELECTIONS
It’s also important to understand that the macro recorder doesn’t always generate
the most efficient code. If you examine the generated code, you’ll see that Excel
Search JabSto ::




Custom Search