XL: How to Assign a Macro to an Option Button

Last reviewed: February 2, 1998
Article ID: Q141689
The information in this article applies to:
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel 98 Macintosh Edition

SUMMARY

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

MORE INFORMATION

To create an option button, make sure the Forms toolbar is visible. In Microsoft Excel 97 or Microsoft Excel 98 Macintosh Edition, point to Toolbars on the View menu, and then click Forms. To display the Forms toolbar in Microsoft Excel versions 5.0 and 7.0, follow these steps:

  1. On the View menu, click Toolbars.

  2. In the Toolbar dialog box, click Forms.

  3. Click OK.

To create an option button and assign a macro to it, follow these steps:

  1. On the Forms toolbar, click Option Button and draw the outline of the button on the sheet.

  2. Select any cell in the worksheet.

  3. In Microsoft Excel 97 or Microsoft Excel 98 Macintosh Edition, use the right mouse button to click the Option button and click Assign Macro on the shortcut menu. In Microsoft Excel 5.0 or 7.0, use the right mouse button to click the option button (or press COMMAND and click it on a Macintosh computer), and then click Assign Macro on the Tools menu.

  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 be run.

REFERENCES

Microsoft Excel Version 7.0

For more information about assigning a macro to a control, click Answer Wizard on the Help menu and type:

  how do I assign a macro to a control

Microsoft Press: "Microsoft Excel/Visual Basic Programmer's Guide," version 7.0, Chapter 8, "Controls and Dialog Boxes"

Microsoft Excel Version 5.0

"Visual Basic User's Guide," version 5.0, Chapter 11, "Controls and Dialog Boxes"

For more information about Assigning a Macro to a Control in Microsoft Excel version 5.0, choose the Search button in Help and type:

   option buttons, creating


Additional query words: 5.00 5.00a 5.00c 7.00 8.00 XL97 assigning
Keywords : kbprg
Version : WINDOWS: 5.0,7.0,97; MACINTOSH: 5.0,98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.