宏以删除所选范围内的activex复选框

时间:2013-06-11 09:10:58

标签: vba excel-vba excel

我正在尝试使用下面的代码删除'ActiveX'复选框。但是,它不起作用。请建议。

Sub CheckboxRemove()
    Dim cl As Range
    Dim cb As Object

    For Each cl In Selection
        Set cb = ActiveSheet.CheckBoxes.Delete()
    Next cl

    Set cl = Nothing
    Set cb = Nothing
End Sub

例如,我已将这些ActiveX复选框从A1放置到F1单元格区域。我将从A1:F1中选择单元格,当我运行此宏时,应删除这些复选框。请指教

1 个答案:

答案 0 :(得分:0)

将复选框视为形状,然后检查左上角单元格的位置:

Sub CheckKiller()
Dim s As Shape
For Each s In ActiveSheet.Shapes
    If s.Type = 12 Then
        If Not Intersect(s.TopLeftCell, Selection) Is Nothing Then
            s.Delete
        End If
    End If
Next
End Sub