Knowledge Base

How to assign a macro to an option button in Excel

Article ID: 141689

Article Last Modified on 1/19/2007


APPLIES TO


This article was previously published under Q141689

SUMMARY

In Microsoft Excel, you can assign a macro to a custom option button so that when the option button is selected, the macro runs.

MORE INFORMATION

To create an option button in Microsoft Office Excel 2003 and in earlier versions of Excel, make sure that the Forms toolbar is visible. To display the Forms toolbar, point to Toolbars on the View menu, and then click Forms.

To create an option button in Microsoft Office Excel 2007, make sure that you add Option Button (form control) to the Quick Access Toolbar. To do this, follow these steps:
  1. Click the Microsoft Office Button, and then click Excel Options.
  2. Click the Customize category, select All Commands in the Choose commands from list, select Option Button (form control), and then click OK.
To create an option button and to assign a macro to it, follow these steps:
  1. In Excel 2003 and in earlier versions of Excel, click Option Button on the Forms toolbar, and then draw the outline of the button on the sheet.

    In Excel 2007, click Option Button (form control) on the Quick Access Toolbar, and then draw the outline of the button on the sheet.
  2. Select any cell in the worksheet.
  3. In versions of Excel that are for Microsoft Windows, right-click the option button, and then click Assign Macro.

    In versions of Excel that are for Macintosh, press COMMAND while you click or press CTRL while you click, depending on your operating system version. Then, click Assign Macro.
  4. In the Assign Macro dialog box, click the name of the macro that you want to assign to the option button, and then click OK.
When you click the option button, the macro will run.

Additional query words: XL97 assigning XL XL2000 XL2002 XL2003 XL2007

Keywords: kbhowto kbprogramming KB141689