Excel Checkbox VBA Help - Master checkbox to tick all checkboxes in a range

ClaireD

New Member
Joined
Nov 29, 2016
Messages
25
Hi there,

I'm having some problems with a macro in Excel. I have a sheet full of checkboxes. I need to put in multiple "master checkboxes". By selecting a master checkbox I would like to tick all checkboxes in a given range of cells.

The first master checkbox is in E11 (Check Box 894). the range of checkboxes it needs to control are in cells E12 onwards. There will be this set up in each column of the spreadsheet (about 20 or so).

Currently I have the following code but this is turning all of the checkboxes on and off. I can't work out how to select just a few checkboxes instead of all of them.

Code:
Sub SelectAll_Click()
Dim CB As CheckBox
For Each CB In ActiveSheet.CheckBoxes
  If CB.Name <> ActiveSheet.CheckBoxes("Check Box 894").Name Then
    CB.Value = ActiveSheet.CheckBoxes("Check Box 894").Value
  End If
Next CB
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Perhaps something like:-
Alter for rows/Columns
Code:
Sub SelectAll_Click()
Dim CB As CheckBox
For Each CB In ActiveSheet.CheckBoxes
  If CB.Name <> ActiveSheet.CheckBoxes("Check Box 894").Name Then
    If CB.TopLeftCell.Row > 11 Then
        CB.Value = ActiveSheet.CheckBoxes("Check Box 894").Value
    End If
  End If
Next CB
End sub
 
Upvote 0
Perhaps something like:-
Alter for rows/Columns
Code:
Sub SelectAll_Click()
Dim CB As CheckBox
For Each CB In ActiveSheet.CheckBoxes
  If CB.Name <> ActiveSheet.CheckBoxes("Check Box 894").Name Then
    If CB.TopLeftCell.Row > 11 Then
        CB.Value = ActiveSheet.CheckBoxes("Check Box 894").Value
    End If
  End If
Next CB
End sub

Hi Mick,

thanks for getting back to me so quickly. How can I adjust this for my desired range? For example column E from E12 onwards??
 
Upvote 0
try:-
Code:
Sub SelectAll_Click()
Dim CB As CheckBox
For Each CB In ActiveSheet.CheckBoxes
  If CB.Name <> ActiveSheet.CheckBoxes("Check Box 894").Name Then
    If CB.TopLeftCell.Row > 11 Or CB.TopLeftCell.Column > 4 Then
        CB.Value = ActiveSheet.CheckBoxes("Check Box 894").Value
     End If
   End If
Next CB
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,547
Members
449,089
Latest member
davidcom

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