Excel VBA Option Buttons - How Do You Cancel Them?
I am trying to deselect radio buttons
and I cannot figure out how to do it. My last attempt looks like this:
Sheet1.Shapes("STCT" & strNumbers).ControlFormat.Value = xlOff
If name radio button
is STCT04
(or 05, or 06, or ... you get a pattern) and the part number of the name is stored in a string variable. I have also tried this
Sheet1.Shapes("STCT" & strNumbers).Value = False
Bad luck. I have googled quite a bit and 95% of the time commenters suggest one of the two above and the question poster always says it worked. This is not for me.
What should I do then?
Edit: I have a list of options to choose from, each with a button assigned. I have 10 options, but the user can sometimes only choose from 5 of them 10. (This depends on other things in my book.) In these cases (if the option does not apply), I would like to set the property to "Value" or " the "False" button is on. When I do this (change one of the two properties) it also overrides every pre-existing selection. (As if the macro call button was pressed.) Hope this makes sense.
Ex: suppose option 2 is selected the solution is not final, but I have it selected. Then it changes something and excludes option 3 from the list of options. When I change one of the aforementioned two properties of Button3, parameter 2 also changes to unselected.
source to share
Use the property Value
.
Using the ActiveX select button:
Dim ole As OLEObject
Set ole = Sheet1.Shapes("STCT" & strNumbers).OLEFormat.Object
Dim op As MSForms.OptionButton
Set op = ole.Object
op.Value = False
By button form options:
Dim op As OptionButton
Set op = Sheet1.Shapes("STCT" & strNumbers).OLEFormat.Object
op.Value = False
source to share