PDA

View Full Version : [SOLVED] Clearing shapes



mdmackillop
09-26-2005, 11:19 AM
Clearing shapes requires selecting then first, but if there are no shapes, the ActiveCell is deleted. What is the neatest way around this?


Sub DeleteDrawingObjects()
'Delete drawing objects from sheet
ActiveSheet.Shapes.SelectAll
Selection.Delete
End Sub

Jacob Hilderbrand
09-26-2005, 11:26 AM
If ActiveSheet.Shapes.Count > 0 Then

MWE
09-26-2005, 11:35 AM
Clearing shapes requires selecting then first, but if there are no shapes, the ActiveCell is deleted. What is the neatest way around this?


Sub DeleteDrawingObjects()
'Delete drawing objects from sheet
ActiveSheet.Shapes.SelectAll
Selection.Delete
End Sub


how about


Sub DeleteDrawingObjects()
'Delete drawing objects from sheet
ActiveSheet.Shapes.SelectAll
If ActiveSheet.Shapes.Count > 0 Then Selection.Delete
End Sub

mdmackillop
09-26-2005, 01:32 PM
Thanks both. It's been a long, long day and the brain has stopped working!

Jacob Hilderbrand
09-26-2005, 01:50 PM
lol, glad to help :beerchug:

Take Care

Ivan F Moala
09-26-2005, 09:03 PM
No need to select them ...


ActiveSheet.DrawingObjects.Delete