Master checkbox to select some but not all other checkboxes

DLombard

Board Regular
Joined
Nov 12, 2004
Messages
52
I have 5 categories, each with a number elements, and each element has a check box linked to a cell. Can I create a 5 master check boxes, each to link to all the elements in a given category? I have been able to figure out how to link the master to ALL checkboxes in the active sheet, but not to multiple but selective checkboxes. Grateful for any input! I am using ActiveX checkboxes, in case that is of importance.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
A few examples for you
Important - Name is CheckBox\Properties\ Name

Code:
[COLOR=#ff0000][I]'array of category checkbox names[/I][/COLOR] - assign CheckBox11 value
Private Sub CheckBox11_Click()
    Dim obj As OLEObject, V As Variant, N As Variant
    V = CheckBox11.Object.Value
    For Each N In Array("CheckBox1", "CheckBox2", "CheckBox3", "CheckBox4", "CheckBox5")
        Me.OLEObjects(N).Object.Value = V
    Next N
End Sub
Code:
[I][COLOR=#ff0000]'common start to names[/COLOR][/I] - assign CheckBox12 value
Private Sub CheckBox12_Click()
    Dim obj As OLEObject, V As Variant
    V = CheckBox12.Object.Value
    For Each obj In Me.OLEObjects
        If TypeName(obj.Object) = "CheckBox" Then
            If Left(obj.Name, 4) = "catA" Then obj.Object.Value = V
        End If
    Next obj
End Sub
Code:
[I][COLOR=#ff0000]'common start to caption[/COLOR][/I] - assign CheckBox13 value
Private Sub CheckBox13_Click()
    Dim obj As OLEObject, V As Variant
    V = CheckBox13.Object.Value
    For Each obj In Me.OLEObjects
        If TypeName(obj.Object) = "CheckBox" Then
                If Left(obj.Object.Caption, 4) = "catB" Then obj.Object.Value = V
        End If
    Next obj
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
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