How to assign a macro to an option button in Excel (141689)



The information in this article applies to:

  • Microsoft Office Excel 2003
  • Microsoft Excel 2002
  • Microsoft Excel 2000
  • Microsoft Excel 97 for Windows
  • Microsoft Excel 2004 for Mac
  • Microsoft Excel X for Mac
  • Microsoft Excel 2001 for Mac
  • Microsoft Excel 98 Macintosh Edition

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, 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 and to assign a macro to it, follow these steps:
  1. On the Forms toolbar, click Option Button, 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 the Macintosh, depending on your operating system version, press COMMAND while you click, or press CTRL while you click. 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.

REFERENCES

For more information about how to assign a macro to a control, click Microsoft Excel Help on the Help menu, and then type Run a macro. In the resulting list of topics, click Run a macro, and then click Start a macro from a button or graphic control.

Modification Type:MajorLast Reviewed:1/27/2005
Keywords:kbhowto kbProgramming KB141689