user2572407
user2572407

Reputation: 23

How to delete only 1 checkbox from any particular cell?

How to delete only 1 checkbox from any particular cell(say in "C38") using Excel VBA?

Upvotes: 2

Views: 222

Answers (1)

user2140173
user2140173

Reputation:

Here is a little guide to how to delete a specific shape

shape name

As you can see, selecting a shape will show you its name in the Name box (placed on the left side of the formula box). In the above example, the name of the selected shape is Rectangle 1
If you want to delete a specific shape you have to know its name (well, if unless it's a specific shape that has its own properties different than any other shape but I will not cover this in here)
The easiest way to get the name of the shape you want to delete it's to click on the shape and look for the name in the Name box.
Once you know the name you can modify your current code and add an if statement to get a match on one item from Shapes collection.

Sub DeleteShape()
    Dim vShape
    For Each vShape In ActiveSheet.Shapes
        If StrComp(CStr(vShape), CStr("Rectangle 1"), 1) = 0 Then
            vShape.Delete
            Exit For
        End If
    Next
End Sub

Upvotes: 1

Related Questions