ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to assign a macro to hundreds of option buttons at once (https://www.excelbanter.com/excel-programming/420011-code-assign-macro-hundreds-option-buttons-once.html)

Carl

Code to assign a macro to hundreds of option buttons at once
 
I have hundreds of option buttons that need to have the same macro assigned
to each (too many to do manually). I am doing this so that when a button is
selected it will change a cell in the worksheet and run a worksheet change
macro. Thanks in advance!

Peter T

Code to assign a macro to hundreds of option buttons at once
 
If you want to assign the same macro to all (Forms style) optionbutons on
the sheet, simply

ActiveSheet.OptionButtons.OnAction = "myMacro"

Otherwise you will need to loop option buttons looking for something
particular about one of the properties to dictate the OnAction string.

In passing, if you mean call worksheet change event code I doubt that's the
best approach.

Regards,
Peter T


"Carl" wrote in message
...
I have hundreds of option buttons that need to have the same macro assigned
to each (too many to do manually). I am doing this so that when a button
is
selected it will change a cell in the worksheet and run a worksheet change
macro. Thanks in advance!





All times are GMT +1. The time now is 07:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com