Excel 2019 Bible

(singke) #1

Part VI: Automating Excel



  1. Choose Developer ➪ Code ➪ Macros (or press Alt+F8). The Macro dialog box
    appears.

  2. Select the macro name from the list.

  3. Click the Options button. The Macro Options dialog box, shown in Figure 42.11,
    appears.

  4. 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).

  5. Click OK to return to the Macro dialog box.

  6. 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:


  1. 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.

  2. 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.

  3. Click the worksheet and drag to draw the button. When you release the mouse
    button, the Assign Macro dialog box appears.

  4. Select the macro from the list.

  5. Click OK to close the Assign Macro dialog box.

  6. (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.

Free download pdf