sumendu kumar
sumendu kumar

Reputation: 1

How to delete multiple checkbox in Excel by VBA?

I am trying to delete multiple checkoxes using VBA.

The code i have so far is as as follows:

Sub DeleteCheckbox()
    Dim cb As CheckBox

    For Each cb In Sheets("Job_Card_Update").CheckBoxes
        If cb.TopLeftCell.Address = Sheets("Job_Card_Update").Range("M13:M20").Address Then cb.Delete
    Next
End Sub

Upvotes: 0

Views: 1028

Answers (1)

user6432984
user6432984

Reputation:

Use the Application.Intersect Method (Excel) to tests if multiple ranges intersect, share cells with, each other.

Dim cb As CheckBox
With Sheets("Job_Card_Update")
    For Each cb In .CheckBoxes
        If Not Intersect(cb.TopLeftCell, .Range("M13:M20")) Is Nothing Then cb.Delete
    Next
End With

Upvotes: 1

Related Questions