1

I am trying to delete the 'ActiveX' check box using below code. However, it is not working. Kindly advise.

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

For an example, I have placed these ActiveX check boxes from A1 to F1 cell range. I will select the cells from A1:F1 and when I run this macro then these checkboxes should be deleted. Please advise

Community
  • 1
  • 1
user2457968
  • 99
  • 3
  • 4
  • 11
  • Hi, the answer provided on http://stackoverflow.com/questions/15509820/how-do-delete-all-checkboxes-in-a-range-of-cells or http://www.ozgrid.com/forum/showthread.php?t=154797 might be of use – Steph Locke Jun 11 '13 at 09:30
  • also [this](http://stackoverflow.com/questions/16818207/excel-vba-uncheck-all-checkboxes-across-entire-workbook-via-commandbutton/16818828#16818828) but change the value changing to .Delete –  Jun 11 '13 at 12:39

1 Answers1

0

Treat the checkboxes as Shapes and then check to the position of the upper left hand cell:

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
Gary's Student
  • 95,722
  • 10
  • 59
  • 99