Microsoft Office Tutorials and References
In Depth Information
Automating Commands with Macros
4. (Optional) Click the Shortcut key text box and then enter the letter of
the alphabet that you want to assign to the macro.
For this example macro, press Shift+C to assign Ctrl+Shift+C as the
shortcut keystroke (so as not to disable the ready-made Ctrl+C shortcut).
Next, you need to decide where to save the new macro that you’re
building. Select Personal Macro Workbook on the Store Macro In
dropdown list box to be able to run the macro anytime you like. Select This
Workbook (the default) when you need to run the macro only when the
current workbook is open. Select New Workbook if you want to open a
new workbook in which to record and save the new macro.
5. Click the Personal Macro Workbook, New Workbook, or This
Workbook option on the Store Macro In drop-down list to indicate
where to store the new macro.
For this example macro, select the Personal Macro Workbook so that you
can use it to enter the company name in any Excel workbook that you
create or edit.
Next, you should document the purpose and function of your macro
in the Description list box. Although this step is purely optional, it is a
good idea to get in the habit of recording this information every time
you build a new macro so that you and your co-workers can always
know what to expect from the macro when it’s run.
6. (Optional) Click the Description list box and then insert a brief
description of the macro’s purpose in front of the information
indicating the date and who recorded the macro.
Now you’re ready to close the Record Macro dialog box and start
recording your macro.
7. Click OK to close the Record Macro dialog box.
The Record Macro dialog box closes and the circular red Record Macro
button on the Status bar and the Developer tab becomes a square, blue
Stop Recording button.
On the Macro button’s drop-down menu on the Ribbon’s View tab and
Code group on the Developer tab, you find a Use Relative References
option. You click this drop-down menu item or command button when
you want the macro recorder to record the macro relative to the
position of the current cell. For this example macro, which enters the
company name and formats it in the worksheet, you definitely need to
click the Use Relative References button before you start recording
commands. Otherwise, you can use the macro only to enter the company
name starting in cell A1 of a worksheet.
8. (Optional) Click the Use Relative References option on the Macros
button’s drop-down menu on the View tab or click the Use Relative
References button on the Developer tab if you want to be able to play
back the macro anywhere in the worksheet.