I want to
ActiveSheet.DrawingObjects.Delete
Except "Button 219" and "Button 221"
What would be my VBA approach?
Michael
I want to
ActiveSheet.DrawingObjects.Delete
Except "Button 219" and "Button 221"
What would be my VBA approach?
Michael
Try this Michael:
[VBA]Sub delSomeshapesFromAllSheets()
Dim Shp As Shape
Dim wk As Worksheet
For Each wk In ActiveWorkbook.Worksheets
For Each Shp In wk.Shapes
If Shp.Name <> "Button 219" And Shp.Name <> "Button 221" Then
Shp.Delete
End If
Next
Next
End Sub[/VBA]
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
Sorry Michael, I misread the question. The previous code was for all worksheets in the workbook. The following is for the active worksheet only...
[VBA]Option Explicit
Sub delSomeshapesFromAllSheets()
Dim Shp As Shape
For Each Shp In ActiveSheet.Shapes
If Shp.Name <> "Button 219" And Shp.Name <> "Button 221" Then
Shp.Delete
End If
Next
End Sub[/VBA]
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
Thank You very much!
That worked charmingly!
Michael
Be sure to mark your thread solved using the thread tools at the top of the page.
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln