Part VI: Automating Excel
- Choose Developer ➪ Code ➪ Macros (or press Alt+F8). The Macro dialog box
appears.
- Select the macro name from the list.
- Click the Options button. The Macro Options dialog box, shown in Figure 42.11,
appears.
- Specify the shortcut key. Use a single letter (for a Ctrl+letter shortcut), or press
Shift and enter an uppercase letter (for a Ctrl+Shift+letter shortcut).
- Click OK to return to the Macro dialog box.
- Click Cancel to close the Macro dialog box.
FIGURE 42.11
Use the Macro Options dialog box to add or change a shortcut key for a macro.
Assigning a macro to a button
After you record a macro and test it, you may want to assign the macro to a button placed
in a worksheet. You can follow these steps to do so:
- If the macro is a general-purpose one that you plan to use in more than a sin-
gle workbook, make sure the macro is stored in your Personal Macro Workbook.
- Choose Developer ➪ Controls ➪ Insert and then click the icon identified as
Button (Form Control). Figure 42.12 shows the list of controls. Move your mouse
pointer over the icons, and you will see a ScreenTip that describes the control.
- Click the worksheet and drag to draw the button. When you release the mouse
button, the Assign Macro dialog box appears.
- Select the macro from the list.
- Click OK to close the Assign Macro dialog box.
- (Optional) Change the text that appears on the button to make it descriptive;
right-click the button, choose Edit Text from the shortcut menu, and make
your changes.