gpt4 book ai didi

excel - 通过 CommandButton 取消选中整个工作簿中的所有复选框

转载 作者:行者123 更新时间:2023-12-03 07:34:25 24 4
gpt4 key购买 nike

我想要一个代码来取消选中工作簿中所有工作表的所有名为“CheckBox1”的复选框。不幸的是,我当前的代码不起作用,我不确定为什么 - 它只适用于事件工作表。

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

最佳答案

此代码遍历所有工作表(名为 Sheet100OtherSheet 的工作表除外)并取消选中 所有名为 CheckBox1

ActiveX 复选框
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 复选框,忽略使用的名称

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

要取消选中电子表格上的所有 Form Control 复选框,请使用

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

关于excel - 通过 CommandButton 取消选中整个工作簿中的所有复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16818207/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com