In Microsoft Excel, you can assign a macro to a custom
option button so that when the option button is selected, the macro
runs.
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:
- Click the Microsoft Office Button, and then click
Excel Options.
- 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:
-
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. - Select any cell in the worksheet.
- 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. - 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.