Adding Code to or Editing Recorded Macros

Suppose you record a macro that enters a series of labels, sets their font, and then draws a border around them. Then you discover that you forgot a step or recorded a step incorrectly—you chose the wrong border format, for example. What do you do?

To add code to an existing macro, you can record actions in a temporary macro and then transfer the code to the macro you want to change. For example, to add to the CompanyAddress macro a step that sets the font options for the company’s name to 14-point Cambria Bold Italic, follow these steps:

  1. Switch to the worksheet containing the address you typed earlier, and select cell A6, which contains the name of the company.

  2. Turn on the macro recorder. In the Record Macro ...

Get Microsoft® Excel® 2010 Inside Out now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.