Excel > Excel 2003 Advanced > Macros

Assign a Macro to a Button

You can run a macro from a button on a Toolbar, a button on the sheet or any other graphic control.

Add a macro to a toolbar button

  1. Click Customize from the Tools menu
  2. Click the Commands tab
  3. Select Macros in the Categories list
  4. Macros category

  5. In the Commands list, drag the Custom button onto the toolbar. A black line appears indicating the position of the button on release of the mouse button
  6. Dragging button onto toolbar

  7. Right click the toolbar button and click Assign Macro on the shortcut menu
  8. Select the macro from the list and click Ok
  9. Assign a macro to a toolbar button

    The button can now be seen on the toolbar and is just one click away whenever needed.

The edit or remove a toolbar button, the Customise dialogue box needs to be open. Click Customise from the Tools menu and then right click the button. Editing options include changing the button image, changing its display name and assigning a different macro.

Click and drag the button off the toolbar to remove it. Remember, the Customise dialogue box needs to be open.

Add a macro to a button on the spreadsheet

Adding a button to the spreadsheet is easier using the Forms toolbar.

  1. Click View > Toolbars and select Forms to view the Forms Toolbar
  2. Click the Button icon
  3. Button on the Forms toolbar

  4. Draw the button onto the sheet
  5. On releasing the mouse button the Assign macro dialogue box appears
  6. Assign Macro to a worksheet button

  7. Select the macro from the list and click Ok
  8. Type a name to appear as the label for the button

To format the button, change the button text or assign a different macro at any time, simply right click the button and select the appropriate option.

Right clicking the worksheet button

Add a macro to a graphic object

It is possible to assign a macro to a graphical object such as a shape or a picture.

  1. Right click on the graphical object
  2. Select Assign Macro from the shortcut menu
  3. Formatting a shape

  4. Select the macro from the list and click Ok

Follow us on

Facebook  Twitter  You Tube