How do I group Option Buttons?

AlInVegas

New Member
Joined
Dec 31, 2007
Messages
19
I am creating a six question questionnaire with yes no answers. If yes is selected for any of the questions, additional questions appear further down the page. I was attempting to use option buttons, but could not group them into 6 separate groups of 2. I had used checkboxes to accomplish the goal in a clumsy fashion and ran into a bit of a problem. In this example checkbox1 is yes, checkbox2 is no. When checkbox one is selected, it changes the value for Checkbox2 if it is checked. This, in turn, executes the code for checkbox2. Is there a way to change the value of checkbox2 without executing the checkbox2 Click() subroutine OR is there a better use of option button code that is available?

Private Sub CheckBox1_Click()
If CheckBox2.Value = True Then CheckBox2.Value = False
If CheckBox1.Value = True And Range("SOD").EntireRow.Hidden = True Then Range("SOD").EntireRow.Hidden = False
If CheckBox1.Value = False And Range("SOD").EntireRow.Hidden = False Then Range("SOD").EntireRow.Hidden = True
--------------------------------------------------------
Private Sub CheckBox2_Click()
If CheckBox1.Value = True Then CheckBox1.Value = False
If Range("SOD").EntireRow.Hidden = False Then Range("SOD").EntireRow.Hidden = True
Range("Check1").Value = ((CheckBox1.Value = True) * 1) + ((CheckBox2.Value = True) * 2)
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi AlInVegas,

To put option buttons in separate groups, simply give the ones you want to be grouped a unique group name (the GroupName property of each optionbutton).

If you want to do the same with Forms-type option buttons, first create a Group Box (from the Controls Toolbar) and create (draw) each option button within the desired Group Box.

Damon
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,864
Members
449,052
Latest member
Fuddy_Duddy

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