问题描述
我想要一个代码,可以取消选中工作簿中所有工作表中名为CheckBox1"的所有复选框.不幸的是,我当前的代码不起作用,我不知道为什么 - 它只适用于活动工作表.
I would like to have a code that unchecks all checkboxes named "CheckBox1" for all sheets across the workbook. My current code unfortunately doesn't work, and I'm not sure why - it only works for the active sheet.
Private Sub CommandButton1_Click()
Dim Sheet As Worksheet
For Each Sheet In ThisWorkbook.Worksheets
Select Case CheckBox1.Value
Case True: CheckBox1.Value = False
End Select
Next
End Sub
推荐答案
此代码遍历所有工作表(名为 Sheet100
和 OtherSheet
的工作表除外>) 并取消选中所有名为 CheckBox1
ActiveX
的复选框em>
This code iterates through all sheets (except sheets named Sheet100
and OtherSheet
) and unchecks all your ActiveX
checkboxes named CheckBox1
Sub uncheck_boxes()
Dim ws As Worksheet
Dim xbox As OLEObject
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Sheet100" And ws.Name <> "OtherSheet" Then
For Each xbox In ws.OLEObjects
ws.OLEObjects("CheckBox1").Object.Value = False
Next
End If
Next
End Sub
取消选中所有工作表中的所有 ActiveX
复选框,而不管使用的名称
To uncheck all ActiveX
checkboxes in all sheets disregarding the names used
Sub uncheck_all_ActiveX_checkboxes()
Dim ws As Worksheet
Dim xbox As OLEObject
For Each ws In ThisWorkbook.Worksheets
For Each xbox In ws.OLEObjects
ws.OLEObjects(xbox.Name).Object.Value = False
Next
Next
End Sub
要取消选中电子表格上的所有表单控件复选框
To uncheck all Form Control checkboxes
on a spreadsheet use
Sub uncheck_forms_checkboxes()
Dim ws As Worksheet
Dim xshape As Shape
For Each ws In ThisWorkbook.Worksheets
For Each xshape In ws.Shapes
If xshape.Type = msoFormControl Then
xshape.ControlFormat.Value = False
End If
Next
Next
End Sub
这篇关于通过 CommandButton 取消选中整个工作簿中的所有复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!