title: Check box to select and deselect all other check boxes in spreadsheet
body: <p>I have a spreadsheet that pulls line items in with check boxes for each line item. I would like to put a check box at the top that will select and deselect all the other check boxes in the spreadsheet when it is selected/deselected. Following is the code I have so far which will select all the check boxes if my "Check Box 1" is selected but it won't deselect them if it is deselected. What do I need to add to make the boxes also deselect if "Check Box 1" is deselected. Thanks for any help.</p>
  
  <pre><code>Sub SelectAllCheckBox()
  Dim CB As CheckBox
  If ActiveSheet.CheckBoxes("Check Box 1").Value Then
      For Each CB In ActiveSheet.CheckBoxes
          If CB.Name &lt;&gt; ActiveSheet.CheckBoxes("Check Box 1").Name Then
              CB.Value = True
          End If
      Next CB
  End If
  End Sub
  </code></pre>
  
  <p>I am also running into another problem. I have a macro to clear the sheet so different macros can run. This macro has code in it that deletes all check boxes. How would I word the code to make it not delete "Check Box 1". This is the code I have.</p>
  
  <pre><code>Sheets("Quote Sheet").Select
  Range("D3:D7").Select
  Selection.ClearContents
  Rows("11:1000").Select
  Selection.Delete Shift:=xlUp
  ActiveSheet.CheckBoxes.Delete
  Selection.FormatConditions.Delete
  </code></pre>
  
  <p>I tried the following but it didn't work.</p>
  
  <pre><code>Sheets("Quote Sheet").Select
  Range("D3:D7").Select
  Selection.ClearContents
  Rows("11:1000").Select
  Selection.Delete Shift:=xlUp
  If CB.Name &lt;&gt; ActiveSheet.CheckBoxes("Check Box 1").Name Then    
  ActiveSheet.CheckBoxes.Delete
  Selection.FormatConditions.Delete
  </code></pre>