Write to cell if all OptionButtons are deselected

erictaveren

New Member
Joined
Aug 6, 2018
Messages
3
Hello,

I've got a command button on userform that is checking a lot of options with one click. One of the things I need it to check is if all the OptionButtons (6 of them) are deselected. If so, a cell needs to populate a value. If any are clicked, I need it to move on to the rest of its task. This is what I found online to help. Obviously I don't want to leave the sub if any are checked, that's one problem. My second problem is that whether or not something is checked my cell gets populated. Does anyone have a solution?

If OptionButton1.Value = Checked _
Or OptionButton2.Value = Checked _
Or OptionButton3.Value = Checked _
Or OptionButton4.Value = Checked _
Or OptionButton5.Value = Checked _
Or OptionButton6.Value = Checked Then
Exit Sub
Else: Sheets("Sheet2").Range("AC1") = "Denied for all retention workouts."
End If
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
If those option buttons are linked, the user can't uncheck all of them.

Also, the .Value of an Optionbutton is either True or False, not checked.

Code:
If OptionButton1.Value Or OptionButton2.Value Or OptionButton3.Value _
              Or OptionButton4.Value Or OptionButton5.Value Or OptionButton6.Value Then
    Exit Sub
Else
    Sheets("Sheet2").Range("AC1").Value = "Denied for all retention workouts"
End If
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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