View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Delete all buttons on sheet

This may work if the number of buttons isn't too large (whatever that means).

activesheet.buttons.delete



"J.W. Aldridge" wrote:

I inadvertently created a bunch of buttons on a sheet. I first tried
manually deleting them one by one but there are hundreds of them. I
found this code and ammended it to delete each button one by one, but
I keep running into a runtime error because I've deleted some of the
buttons out of sequence and it looks to actually run each line whether
the button number is there or not.

Is there a way that I can delete all buttons on a page regardless of
the number?

Sub DeleteButtons()
Application.DisplayAlerts = True
ActiveSheet.Unprotect
ActiveSheet.Shapes("Button 595").Select
Selection.Cut
' *** I ommitted the code for buttons 594 thru 2 so that I could post
here, but it's the same***
ActiveSheet.Shapes("Button 1").Select
Selection.Cut
Application.DisplayAlerts = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFiltering:=True
End Sub


--

Dave Peterson