I have 2 checkboxes on a worksheet. The second one has no purpose unless the first one is checked. I would like for the second checkbox to be greyed out until I click on the first one. Is this possible on a worksheet (I don't use a user form)
I have 2 checkboxes on a worksheet. The second one has no purpose unless the first one is checked. I would like for the second checkbox to be greyed out until I click on the first one. Is this possible on a worksheet (I don't use a user form)
Here is how to do it with ActiveX checkboxes. Needs VBA. (I don't know how to do this with Forms checkboxes but that would also need VBA.)
Edit: If you have them both checked, then uncheck the first one, I also uncheck the second one.
Thank you...This worked as advertised however I have some Mac users of my worksheet so I've been forced to use Forms Control checkboxes.
I was able to come up with the following code for these Form Control checkboxes:
It required setting some similar code on the ThisWorkbook object in the Sub Workbook_Open() section to ensure that that behavior was in place before the checkbox was clicked on the first time.![]()
If Sheet3.Shapes("CheckBox1").OLEFormat.Object.Value = 1 Then Sheet3.Shapes("CheckBox2").OLEFormat.Object.Enabled = True Else Sheet3.Shapes("CheckBox2").OLEFormat.Object.Enabled = False End If
Hello JimDandy,
The Forms Check Box controls don't have a greyed state when disabled. Instead, you could make the control visible or invisible. Copy the code below into a new VBA Module and then assign the macro to "Check Box 1". Be sure to change the names to match those on the worksheet.
![]()
Sub CheckBoxControl() Dim ChkBox1 As Shape Dim ChkBox2 As Shape With ActiveSheet Set ChkBox1 = .Shapes("Check Box 1") Set ChkBox2 = .Shapes("Check Box 2") ChkBox2.Visible = (ChkBox1.ControlFormat.Value > 0) 'ChkBox2.ControlFormat.Enabled = (ChkBox1.ControlFormat.Value > 0) End With End Sub
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
This was extremely helpful, it was just what I needed...Thank you
Hello JimDandy,
You're welcome.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks