Forum Discussion
Ryan M
Jan 25, 2018Copper Contributor
clicking a single checkbox that will then click a specific group of checkboxes within sheet
So I am a rookie when it comes to excel stuff, but have come a long way in last week or two. I have been killing myself trying to figure this out.
I have a form/spreadsheet that I am creating ...
JKPieterse
Jan 25, 2018Silver Contributor
If you name your controls smartly this can be done with a bit of VBA.
Name the checkboxes within a group cbx_1_1, cbx_1_2, cbx_1_3, cbx_1_4
Name each group checkbox: cbxGrp_1, cbxGrp_2, ...
Attach this macro to each group checkbox:
Sub cbxGrp_Click()
Dim oCbx As CheckBox
Dim lValue As Long
Dim sGrp As String
sGrp = Application.Caller
lValue = ActiveSheet.CheckBoxes(sGrp).Value
sGrp = Split(sGrp, "_")(1)
For Each oCbx In ActiveSheet.CheckBoxes
If oCbx.Name Like "cbx_" & sGrp & "_*" Then
oCbx.Value = lValue
End If
Next
End Sub
Shianne_813
Dec 05, 2022Copper Contributor
Hello, I need this solution for a project I am working on, but I am fairly new to excel and I am wondering if you can help me. In my excel document I have 24 check boxes. I am trying to make it so that if I click checkbox21, it will also select checkbox5. And If I click checkbox22, it will also select checkbox5. This code is what I need to do that I think but I am unsure of how to edit this code to suite my needs. I am also stuck on how to group and name the group of checkboxes.
Thanks
Thanks