Microsoft Office Tutorials and References
In Depth Information
Automating Commands with Macros
Even if you don’t add the Developer tab to the Ribbon, the Excel Status bar
at the bottom of the Excel 2013 program window contains a Record Macro
button (the button — it looks like a worksheet with a red dot — to the
immediate right of the Ready status indicator). You click this button to turn on the
macro recorder. Also, the View tab contains a Macros command button with
a drop-down menu containing a Record Macro option.
When you turn on the macro recorder either by clicking the Record Macro
button on the Status bar, clicking the Record Macro option on the Macros
button’s drop-down menu (Alt+WMR), or clicking the Record Macro button
on the Developer tab (Alt+LR), the macro recorder records all your actions in
the active worksheet or chart sheet when you make them.
The macro recorder doesn’t record the keystrokes or mouse actions that you
take to accomplish an action — only the VBA code required to perform the
action itself. This means that mistakes that you make while taking an action
that you rectify won’t be recorded as part of the macro; for example, if you
make a typing error and then edit it while the macro recorder is on, only the
corrected entry shows up in the macro without the original mistakes and
steps taken to remedy them.
The macros that you create with the macro recorder can be stored as part
of the current workbook, in a new workbook, or in a special, globally
available Personal Macro Workbook named PERSONAL.XLSB that’s stored in a
folder called XLSTART on your hard drive. When you record a macro as part
of your Personal Macro Workbook, you can run that macro from any
workbook that you have open. (This is because the PERSONAL.XLSB workbook is
secretly opened whenever you launch Excel, and although it remains hidden,
its macros are always available.) When you record macros as part of the
current workbook or a new workbook, you can run those macros only when the
workbook in which they were recorded is open in Excel.
When you create a macro with the macro recorder, you decide not only the
workbook in which to store the macro but also what name and shortcut
keystrokes to assign to the macro that you are creating. When assigning a
name for your macro, use the same guidelines that you use when you assign
a standard range name to a cell range in your worksheet. When assigning a
shortcut keystroke to run the macro, you can assign
✓ The Ctrl key plus a letter from A to Z, as in Ctrl+Q
✓ Ctrl+Shift and a letter from A to Z, as in Ctrl+Shift+Q
You can’t, however, assign the Ctrl key plus a punctuation or number key
(such as Ctrl+1 or Ctrl+/) to your macro.