Datasheet
Book VIII
Chapter 1
Building and
Running Macros
Macro Basics
705
list box to be able to run the macro anytime you like. Select This Work-
book (the default) when you need to run the macro only when the cur-
rent 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 item 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.
Now, you should document the purpose and functioning 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 coworkers can always
know what to expect from the macro when they run it.
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 record-
ing your macro.
7. Click OK to close the Record Macro dialog box.
When you do this, the Record Macro dialog box closes. The circular
red icon on the Record Macro button both on the Status bar and the
Developer tab changes into a square blue Stop Recording button.
Click the Use Relative References option on the Macros command
button on the View tab or the Use Relative References command button
on the Developer tab (when it’s displayed) when you want the macro
recorder to record the macro relative to the position of the current cell.
Doing this often makes a macro more versatile as it enables you to run
the macro in areas in the worksheet other than the cells used in its origi-
nal recording.
8. (Optional) Click the Use Relative References option on the Macros
command button on the View tab (Alt+WMU) or click the Use Relative
References command button on the Developer tab (Alt+LU) if you
want to be able to play back the macro anywhere in the worksheet.
9. Select the cells, enter the data, and choose the Excel commands
required to perform the tasks that you want recorded just as you nor-
mally would in creating or editing the current worksheet, using either
the keyboard or the mouse or a combination of the two.
For the example macro, all you do is type the company name and click
the Enter button on the Formula bar to complete the entry in the current
36_037385 bk08ch01.qxp 11/17/06 11:08 AM Page 705