Question

I am trying to delete a drop down from a spreadsheet using the following code:

Dim objShape As Shape
For Each objShape In ActiveSheet.Shapes
    objShape.Delete
Next

But objShape returns Application-Defined or Object-Defined Error:

Debug.Print objShape.FormControlType returns xlDropDown
Debug.Print objShape.Name                       returns "Drop Down 250"
Debug.Print objShape.TopLeftCell         returns Application-Defined or Object-Defined Error

ActiveSheet.Cells.Validation.Delete does not get rid of it, nor does using ShapeRange.

Any suggestions on how to eradicate this little bugger would be greatly appreciated.

Was it helpful?

Solution 2

The drop down list was tied to another sheet in the workbook. After deleting the other sheet, the code correctly deleted the shape.

OTHER TIPS

Couple of ideas:

  • Is there some sheet protection?
  • Is the dropdown part of some validation (allowed values can be defined and are usually displayed as a dropdown box).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top