Using a button to select all check boxes (with a wrinkle)


New Member
Jan 22, 2016
I have seen a few tutorials that show how to select all check boxes by selecting a single check box, but I am trying to perform this action by clicking a button and am struggling to adapt the instructions. Also, I would like to perform this action only on check boxes where the related row is not blank.

Example, A1:A3 each contain a check box. B1 and B2 have values, but B3 is blank. I would like to be able to click a button and select only A1 and A2. In actual use, I would likely have 200 rows, each with a check box, and anywhere from 0-199 of the rows may be blank any given time the sheet is loaded.

Any help would be much appreciated!:biggrin:


MrExcel MVP
Mar 10, 2004
Are the checkboxes form controls? Or are they ActiveX controls? If they're the former, try...

[color=darkblue]Option[/color] [color=darkblue]Explicit[/color]

[color=darkblue]Sub[/color] SelectCheckBoxes()

    [color=darkblue]Dim[/color] ws [color=darkblue]As[/color] Worksheet
    [color=darkblue]Dim[/color] oChBx [color=darkblue]As[/color] CheckBox
    [color=darkblue]Set[/color] ws = Worksheets("Sheet1") [color=green]'change the sheet name accordingly[/color]
    [color=darkblue]For[/color] [color=darkblue]Each[/color] oChBx [color=darkblue]In[/color] ws.CheckBoxes
        [color=darkblue]With[/color] oChBx
            [color=darkblue]If[/color] [color=darkblue]Not[/color] Intersect(ws.Columns("A"), .TopLeftCell) [color=darkblue]Is[/color] [color=darkblue]Nothing[/color] [color=darkblue]Then[/color]
                [color=darkblue]If[/color] Len(.TopLeftCell.Offset(, 1)) > 0 [color=darkblue]Then[/color]
                    .Value = [color=darkblue]True[/color]
                    .Value = [color=darkblue]False[/color]
                [color=darkblue]End[/color] [color=darkblue]If[/color]
            [color=darkblue]End[/color] [color=darkblue]If[/color]
        [color=darkblue]End[/color] [color=darkblue]With[/color]
    [color=darkblue]Next[/color] oChBx
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
Hope this helps!

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...