Microsoft Office Tutorials and References
In Depth Information
Using the Macro Recorder
What you see next will look much like Figure 2-12. A small dialog box titled Record Macro will
appear, with default information that only needs your approval by clicking OK to start recording
your macro. Resist the temptation to accept the defaults because now’s the time to get into a few
The Macro Recorder is an excellent teaching tool, and hardly a day goes by when I do not use it
in some way. VBA is just too voluminous a programming language to memorize its every keyword
and nuance. Often as not, I’ll record a macro just to look at the code it produces to learn the proper
syntax of a task dealing with some larger macro I am working on. You will find yourself using the
Macro Recorder in the same way; it’s a terrific source for learning VBA code, as Excel developers of
any skill level will attest.
For this example, the macro you are creating is one you will want to keep and use often. A little
customization is strongly recommended to help you down the road, when you’ll want to remember what
the macro does, why you created it, and what optional keyboard shortcut you assigned to run it.
In the Record Macro dialog box, give the macro a meaningful name. Macro names cannot contain
spaces and they cannot begin with a numeral. Because you are the person doing the sorting, and you
don’t want to make the macro name too long, naming it mySort gives the macro more meaning than
the default name of Macro1 .
In Figure 2-12, notice the small box to the right of Ctrl+ in the Shortcut Key section. You can place
any letter of the alphabet in that field, which, when pressed with the Ctrl key, will be one method
(and a convenient one at that) by which you can run the macro.