从VBA宏的Excel工作簿中取消选择所有复选框 [英] Unselect All CheckBoxes From Excel Workbook with VBA Macro

查看:840
本文介绍了从VBA宏的Excel工作簿中取消选择所有复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含100多个复选框的工作簿。

I have a workbook with over 100 checkboxes.

它们是表单控件复选框

我想一次取消选择所有这些

I would like to un-select them all at once

,将其设置为false。

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

谢谢

推荐答案

如果您有OLEObject样式( ActiveX )复选框,则:

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:

如果他们是表单复选框 work:

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

这篇关于从VBA宏的Excel工作簿中取消选择所有复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆