Run a macro

Microsoft Office Excel 2003

  1. Set the security level to Medium or Low.

    ShowHow?

    1. On the Tools menu, click Options.
    2. Click the Security tab.
    3. Under Macro Security, click Macro Security.
    4. Click the Security Level tab, and then select the security level you want to use.
  2. Open the workbook that contains the macro.
  3. On the Tools menu, point to Macro, and then click Macros.
  4. In the Macro name box, enter the name of the macro you want to run.
  5. Do one of the following:

    Run a macro in a Microsoft Excel workbook

    • Click Run.

      If you want to interrupt, press ESC.

    Run a macro from a Microsoft Visual Basic module

    1. Click Edit.
    2. Click Run Sub/UserForm Button image.

    ShowTip

    If you want to run a different macro while you are in the Visual Basic Editor, click Macros on the Tools menu. In the Macro name box, enter the name of the macro you want to run, and then click Run.

ShowStart a macro from a keyboard shortcut

  1. On the Tools menu, point to Macro, and then click Macros.
  2. In the Macro name box, enter the name of the macro you want to assign to a keyboard shortcut key.
  3. Click Options.
  4. If you want to run the macro by pressing a keyboard shortcut key, enter a letter in the Shortcut key box. You can use CTRL+ letter (for lowercase letters) or CTRL+SHIFT+ letter (for uppercase letters), where letter is any letter key on the keyboard. The shortcut key letter you use cannot be a number or special character such as @ or #.

    Note  The shortcut key will override any equivalent default Microsoft Excel shortcut keys while the workbook that contains the macro is open.

  5. If you want to include a description of the macro, type it in the Description box.

  6. Click OK.
  7. Click Cancel.

ShowStart a macro from a button or graphic control

  1. Click the button or graphic control so that sizing handles appear.
  2. With the graphic object selected, right-click a sizing handle of the button or graphic object to display the shortcut menu.
  3. On the shortcut menu, click Assign Macro.
  4. Do one of the following:
    • To assign an existing macro to the button or graphic object, enter the name of the macro in the Macro name box, and then click OK.
    • To record a new macro to assign to the selected graphic object, click Record. When you finish recording the macro, click Stop Recording Button image on the Stop Recording toolbar.

    • To write a new macro in the Visual Basic Editor, click New. To edit an existing macro, click the name of the macro in the Macro Name box, and then click Edit.

Note  If you assign a macro to a button or other object that is already in use as a hyperlink, the hyperlink information is deleted. From then on, clicking the button or object runs the macro instead.

ShowStart a macro from an area, or hotspot, on a graphic object

  1. Draw another object to create a hot spot for an existing object.
  2. With the second graphic object selected, right-click a sizing handle of the button or graphic object to display the shortcut menu.
  3. On the shortcut menu, click Assign Macro.
  4. Do one of the following:
    • To assign an existing macro to the button or graphic object, enter the name of the macro in the Macro name box, and then click OK.
    • To record a new macro to assign to the selected graphic object, click Record. When you finish recording the macro, click Stop Recording Button image on the Stop Recording toolbar.

    • To write a new macro in the Visual Basic Editor, click New. To edit an existing macro, click the name of the macro in the Macro Name box, and then click Edit.

  5. On the Format menu, click AutoShape, and then click the Color and Lines tab.
  6. Under Fill, click No Fill in the Color box. Under Line, click No Line in the Color box.
  7. Repeat these steps for each hotspot you want to create. You do not need to create a new graphic object for each hotspot.

ShowStart a macro from a toolbar button

  1. On the Tools menu, click Customize.
  2. Do one of the following:
    • If the toolbar that contains the button is not visible, click the Toolbars tab, and then select the check box next to the toolbar name.
    • If the button you want to run the macro from is not on a toolbar, click the Commands tab, and then click Macros in the Categories list. In the Commands list, drag the Custom button onto a toolbar.
  3. Right-click the toolbar button, and then click Assign Macro on the shortcut menu.
  4. Enter the name of the macro in the Macro name box, and then click OK.