Enabling and disabling option buttons in Excel using macros

I'm working with an excel 2002 file and I have a combo box and some option buttons. Depending on the choice in the combo I have to enable/disable some of the option buttons.
I began programming the macro for the OnChange event of the combo but I need to know which is the piece of code to do that, because the sentence

 Worksheets(name).OptionButton1.Enable = True (Or false)

doesn´t work.

I also think about hide the rows containing the option buttons I have to disable but the problem is that the rows dissapeared but the objects (I mean the option buttons) stay together in a row so that's why I'm trying to disable them.

Any solution or another suggestion will be good!

Thanks in advance.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have to point to the combo box in order to change properties of buttons within it, so your code should look like: Worksheets(name).ComboBox(myCombo).OptionButton1.Enable = True (Or false)

If your buttons are not on the combo box, your code should work.  I would use the debugger and singlestep through the call to see what it's doing.
use option buttons from the control toolbox instead of option buttons from the form tool box

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lhdargAuthor Commented:
Callandor: I noticed that I was using the wrong object so I inserted the control toolbox option button so now I have the prooperty panel.

Now I'm trying to change the state  (from enable to disable or the other way round) but I don't know how to do it.
The option button is an object separated from the combo box. What I need is to turn to enable (or disable) some option buttons in case the item selected in the combo is something specific.

I tried with

Worksheets(name).OptionButton.Enable = True

but it says the method or property is nos available for that object.

Any solution?


Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

lhdargAuthor Commented:
Sorry, I was using "enable" instead of "enabled".

The sentence

Worksheets(name).OptionButton.Enabled = True


Many thanks.

I tried recording a macro while selecting a button and altering its properties - I could not capture anything I did after selecting the button.  Apparently, not all objects support dynamic change of properties, so it looks like you need to work around the limitation.  You can change the value in a cell in the spreadsheet, depending on what is selected in the combo box, and then when you press the button, test the value in the cell and decide what to do.  Not very elegant, but VBA is limiting what you can do here.
Glad could help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.