Unselect All CheckBoxes From Excel Workbook with VBA Macro

后端 未结 2 991
甜味超标
甜味超标 2021-01-05 09:23

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

2条回答
  •  无人及你
    2021-01-05 09:54

    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
    

提交回复
热议问题