Link to home
Start Free TrialLog in
Avatar of Frank Freese
Frank FreeseFlag for United States of America

asked on

Form Control - set value of Option Button

Folks,
In my worksheet I have two option buttons as form controls. Each is assigned to a different macro.
When the workbook is activated I would like to set the "Format Control - Control - Value to be 'Unchecked' " for both form controls.
I've even tried changing the named in the "Name Box" from "Option Button 1" to "EvalPos" but that didn't work. If it was an ActiveX control - no problem. But it is a form control.
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

You should be able to use a loop like:

Dim ob as OptionButton
For each on in sheets("sheet name").OptionButtons
   ob.Value = -4146
Next ob

Open in new window

Avatar of Frank Freese

ASKER

Is the code from above line 2 correct?

For each on in sheets("sheet name").OptionButtons
I get an error:
Object does not support this property or method at line 2.
Sorry - typo - it should read
for each ob in sheets("Sheet name").optionbuttons

Open in new window

Only one option button on a sheet can be checked (or unchecked) at the same time.
You could use checkboxes instead.
Another way you could do it would be to put each option button inside it's own 'Group Box' control.
I'm still making myself clear and I apologize.
Regardless of which form control I elect to use - radio or check mark, when the worksheet is activated I would like to clear any checks marks. Now when I open the worksheet the option button and /or check box retains the last selection and is not cleared. I do know when I right click on a form control select Format Control then the tab labeled Control there are two possible values available "Unchecked" and "Checked". I do not know how to set that value to "Unchecked" when the worksheet is activated for the two form controls I am using.User generated imageWhen I tried Rory's suggestion at  40273265 and corrected the typo I received the message "Object does not support this property or method."
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There you go my good man - you nailed it
thanks to all
thank you very much