I am pulling check boxes into a spreadsheet to be used to select certain line items to get a final cost. There are a few unneeded check boxes that get pulled in though, prob
This code will delete any Excel checkbox located at the active cell.
Sub DeleteCheckbox()
Dim cb As CheckBox
For Each cb In ActiveSheet.CheckBoxes
If cb.TopLeftCell.Address = ActiveCell.Address Then cb.Delete
Next
End Sub
In case you're using ActiveX checkboxes, this code will do the job:
Sub DeleteActiveXCheckbox()
Dim obj As OLEObject
Dim cb As MSForms.CheckBox
For Each obj In ActiveSheet.OLEObjects
If TypeOf obj.Object Is MSForms.CheckBox Then
Set cb = obj.Object
If cb.ShapeRange.Item(1).TopLeftCell.Address = _
ActiveCell.Address Then obj.Delete
End If
Next
End Sub