delete method of OLEObject class failed
On my Worksheet, I have a Commandbotton that executes this macro to delete all comboboxes in another sheet:
Sub DeleteShapes()
Dim obj As OLEObject
For Each obj In Sheets("Sheet").OLEObjects
If TypeOf obj.Object Is MSForms. ComboBox Then
obj.Delete
End If
Next
End Sub
This method works most of the time, but sometimes I get this error:
delete method of OLEObject class failed.
I red in this forum, that I should set the TakeFocusOnClick Property of the CommandButton to false, but this didn't help.
could please someone help me?