Need VBA to remove command buttons

B

Bill_S

I used the macro recorder to record a macro to remove command buttons from a
worksheet. The routine gets hung up and says I don't have permission to
delete the buttons. I realized that when I was recording the macro I first
had to put the sheet into design mode and that step was not recorded by the
macro recorder. What is the VBA command to turn on design mode?
 
L

Les Stout

Hello Bill S, you can try the following as well.

ActiveSheet.Shapes("CommandButton1").Delete

You must put in the name of the button if you changed it, the default
name is CommandButton1, CommandButton2 etc....


Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
 
D

Don Guillett

Or, if you don't know the name and you want to delete ALL shapes on a
particular sheet.

Sub deleteALLshapes()
For Each sh In Sheets("sheet3").Shapes
sh.Delete
Next sh
End Sub
 
J

John Keith

Also, make sure that protection is turned off. You can turn it back on after
the delete takes place.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top