How to Record and Run a Macro
Part 2: Recording a Macro
By John Cellini
Published on August 31, 2007
What to Consider Before Recording a Macro
As you learned in Part 1, we can create our own custom commands in Excel. Macros are great time savers and you will want to create a few for your particular needs! Before you record a macro, there are a few important things to consider.
Write Down the Steps and Practice Before Recording
It's essential that you write down the steps you'll be using to record your macro and rehearse them a few times. If you did this in Part 1 as I suggested, then you may already have an idea of how important it is to practice a few times before recording your macro. For one thing, practice may reveal more efficient steps in creating your custom command.
The best reason for practicing is to eliminate mistakes. If you make mistakes during the recording, your mistakes will be recorded and become part of the macro. The exception to this rule is dialog box commands. The Macro Recorder only records the results of your selections when you click OK and not any mistakes you make while the dialog box is open. Macros increase the file size of your workbook substantially, so you want to find the most efficient steps to record your macro and not make any mistakes that will be recorded.
As I mentioned before, a macro is a VBA procedure. When you record a macro, Excel writes the VBA code for you. You want to make sure that the code that is written is clean. Clean code enables your macro to run efficiently and keeps your file size is as small as possible. So, take your time as you record your macro to make sure that it is free of mistakes.
Give Your Macro a Name and Description
When you click on the Record New Macro command in the Tools menu (Tools --> Macro --> Record New Macro) the Record Macro dialog box appears.

In the Record Macro dialog box, give your macro a descriptive name. Macro names must begin with a letter. They can contain letters, numbers, and underscores, but not spaces. In the example above, I separated CompanyName and Date with an underscore instead of a space.
We will discuss assigning shortcut keys to your macros in Part 3.
As you add to your list of macros, it's easy to forget what exactly each macro does. Give your macro a good enough description so that you know what task it performs. Your macros with their descriptions are listed in the Macro dialog box (Tools --> Macro --> Macros).
page 1 | 2 | next page >>