Hiding check boxes

lukemeyer

New Member
Joined
Jun 25, 2011
Messages
15
I am using standard form check boxes and radio buttons and not activeX boxes. Is there a way to link the boxes so when I click box 1 I get box 2 and 3 to show up. If I click box 4, box 5 and 6 show up. Is this possible with standard form options or do I have to do this with activeX controls?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Assign these macros to Check Box 1 and Check Box 4

Code:
Sub CheckBox1_Click()
    ActiveSheet.CheckBoxes("Check Box 2").Visible = ActiveSheet.CheckBoxes("Check Box 1").Value = 1
    ActiveSheet.CheckBoxes("Check Box 3").Visible = ActiveSheet.CheckBoxes("Check Box 1").Value = 1
End Sub

Sub CheckBox4_Click()
    ActiveSheet.CheckBoxes("Check Box 5").Visible = ActiveSheet.CheckBoxes("Check Box 4").Value = 1
    ActiveSheet.CheckBoxes("Check Box 6").Visible = ActiveSheet.CheckBoxes("Check Box 4").Value = 1
End Sub
 
Upvote 0
Maybe

Code:
With ActiveSheet
    .Shapes("Box2").Visible = (.Shapes("Box1").ControlFormat.Value = xlOn)
    .Shapes("Box3").Visible = (.Shapes("Box1").ControlFormat.Value = xlOn)
    .Shapes("Box5").Visible = (.Shapes("Box4").ControlFormat.Value = xlOn)
    .Shapes("Box6").Visible = (.Shapes("Box4").ControlFormat.Value = xlOn)
End With
 
Upvote 0
ok, I am not as average as I thought I was.

Alpha your code worked great for check boxes. I tried to modify it to work on option buttons. (1 option button turns on 2 and 3 the other turns on 4 and 5).

I got this to work fine, but when I go from option 7 to 8 it does not turn off the other cells. What do I have to change for the option buttons to work as check boxes?

My code is below. It is just slightly modified from what Alpha posted.

Sub OptionButton7_Click()
ActiveSheet.CheckBoxes("Check Box 2").Visible = ActiveSheet.OptionButtons("Option Button 7").Value = 1
ActiveSheet.CheckBoxes("Check Box 3").Visible = ActiveSheet.OptionButtons("Option Button 7").Value = 1
End Sub
Sub OptionButton8_Click()
ActiveSheet.CheckBoxes("Check Box 5").Visible = ActiveSheet.OptionButtons("Option Button 8").Value = 1
ActiveSheet.CheckBoxes("Check Box 6").Visible = ActiveSheet.OptionButtons("Option Button 8").Value = 1
End Sub
 
Upvote 0
Code:
Sub OptionButton7_Click()
    ActiveSheet.CheckBoxes("Check Box 2").Visible = True
    ActiveSheet.CheckBoxes("Check Box 3").Visible = True
    ActiveSheet.CheckBoxes("Check Box 5").Visible = False
    ActiveSheet.CheckBoxes("Check Box 6").Visible = False
End Sub

Sub OptionButton8_Click()
    ActiveSheet.CheckBoxes("Check Box 2").Visible = False
    ActiveSheet.CheckBoxes("Check Box 3").Visible = False
    ActiveSheet.CheckBoxes("Check Box 5").Visible = True
    ActiveSheet.CheckBoxes("Check Box 6").Visible = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,894
Members
452,948
Latest member
Dupuhini

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