gpt4 book ai didi

vba - Excel VBA脚本清除列中的所有复选框

转载 作者:行者123 更新时间:2023-12-02 11:44:18 26 4
gpt4 key购买 nike

我正在尝试清除特定单元格范围或按列中的所有事件 X 复选框

这看起来很简单,因为我可以使用下面的代码对整个工作表执行此操作。我只是不确定如何修改它以仅适用于单列或单元格范围。

Sub ClearAllCheckboxes()
Dim Answer As String
Dim MyNote As String
Dim Obj As Object

MyNote = "This will Clear all CheckBoxes Proceed? "
Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "???")

If Answer = vbNo Then
Exit Sub
Else
On Error Resume Next
For Each Obj In ActiveSheet.OLEObjects
Obj.Object.Value = False
Next Obj
End If
End Sub

最佳答案

尝试使用 topleftcell 属性:

Sub ClearAllCheckboxes()
Dim Answer As String
Dim MyNote As String
Dim Obj As Object
dim rg as range

set rg=selection

MyNote = "This will Clear all CheckBoxes Proceed? "
Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "???")

If Answer = vbNo Then
Exit Sub
Else
On Error Resume Next
For Each Obj In ActiveSheet.OLEObjects
if not intersect(rg, obj.topleftcell) is nothing then _
Obj.Object.Value = False
Next Obj
End If
End Sub

关于vba - Excel VBA脚本清除列中的所有复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13236963/

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