Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unselect All CheckBoxes From Excel Workbook with VBA Macro

I have a workbook with over 100 checkboxes.

They are form control checkboxes

I would like to un-select them all at once

that is set them to false.

 Sub clearcheck()
 ActiveSheet.CheckBoxes.Value = False
 End Sub

This works for the active sheet. I would like this code to be for the whole workbook

I have tried looking for the code and messing about with clearing the checkboxes but am none the wiser.

I would really appreciate if some one could guide me

thank you

like image 869
user2533460 Avatar asked Sep 21 '13 00:09

user2533460


People also ask

How do I uncheck all checkboxes in Excel?

Then press F5 key to run this code, and all checked checkboxes have been deselected at once in active worksheet.

How do I delete all checkboxes in Excel VBA?

To delete all checkboxes at a time, go to the Home tab > Editing group > Find & Select > Go To Special, select the Objects radio button, and click OK. This will select all the check boxes on the active sheet, and you simply press the Delete key to remove them.

How do I uncheck in Excel?

Sometimes when you're selecting multiple cells or ranges in Excel, you accidentally select one or more that you didn't intend. You can deselect any cells within the selected range with the Deselect Tool. Pressing the Ctrl key, you can click, or click-and-drag to deselect any cells or ranges within a selection.


1 Answers

If you have OLEObject-style (ActiveX) checkboxes, then:

Sub terranian()
    Dim o As Object
    For Each o In ActiveSheet.OLEObjects
        If InStr(1, o.Name, "CheckBox") > 0 Then
            o.Object.Value = False
        End If
    Next
End Sub

EDIT1:

If they are forms checkboxes , then the following will work:

Sub clearcheck()
    Dim sh As Worksheet
    For Each sh In Sheets
        On Error Resume Next
            sh.CheckBoxes.Value = False
        On Error GoTo 0
    Next sh
End Sub
like image 73
Gary's Student Avatar answered Sep 22 '22 19:09

Gary's Student