Option button on a userform question

birdieman

Well-known Member
Joined
Jan 13, 2016
Messages
551
I want to put an option button on a userform and I want the user to choose between "yes" and "no".

1. Do I put one button on the form and then in the code (a "change" event for the OptionButton1, I guess) do what I need done based on whether TRUE ("on") or FALSE ("off")?

2. Or, do I put two buttons on the form and use code for both buttons? If this is the case, how do I make sure they are both not "on" or "off" at the same time?

Or should I use a check box?
thanks
 
Last edited:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
If it's Yes/No then it's probably better (easier?) to use a checkbox.
 
Upvote 0
If I want to show the user a yes button and no button, would I group two option buttons inside a frame in order for them to be "grouped" together, and therefore not able for both to be "on" at the same time? Is that correct?

thanks for responding
 
Last edited:
Upvote 0
They don't need to be in a frame, you can use their GroupName property to group them.
 
Upvote 0
thank you -- tried it and found out how to link. Which button does the code go into -- does it matter? Then, in the code, I just determine if OptionButton1 is "true" and if so do something, and if not do something else?
 
Upvote 0
Do you need code for the buttons themselves?

What are they going to be used for?
 
Upvote 0
the buttons are labeled "automatic" and "manual". If automatic is clicked, then I want to lock a textbox and set its tab stop to false to prevent user input. If "manual" is clicked, then I want to unlock the textbox, set tab stop to true, and allow user input. There may be other stuff, but that is basically it.

In another textbox's code, I want to be able to check the setting in optionbutton1 (or the other one), and if "automatic" is pushed, then i want to do something else.

hope that helps
 
Upvote 0
You should put the code in both.
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,011
Members
448,935
Latest member
ijat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top