ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete all drawings/shapes except DownArrows (https://www.excelbanter.com/excel-programming/444272-delete-all-drawings-shapes-except-downarrows.html)

Pete[_34_]

Delete all drawings/shapes except DownArrows
 
Hi all

I have written a subroutine to delete all shapes on a sheet but not any
DownArrows

Sub DeleteShapesExceptDownArrows()
Dim MyShape As Object
For Each MyShape In ActiveSheet.Shapes
If MyShape.Name < msoShapeDownArrow Then
MyShape.Delete
End If
Next MyShape
End Sub

However, the routine deletes all shapes regardless!

Any ideas?

--
Regards,
Peter Bircher

AutomateXcel
http://www.automatexcel.co.za/index.html

Cell : 083 233 1628
Email:


Dave Peterson[_2_]

Delete all drawings/shapes except DownArrows
 
The .name property isn't what you want to you. The Name is the string you see
in the namebox (to the left of the formulabar).

I'd try:

Option Explicit
Sub DeleteShapesExceptDownArrows()
Dim MyShape As Shape
For Each MyShape In ActiveSheet.Shapes
If MyShape.AutoShapeType < msoShapeDownArrow Then
MyShape.Delete
End If
Next MyShape
End Sub

On 02/23/2011 03:53, Pete wrote:

Sub DeleteShapesExceptDownArrows()
Dim MyShape As Object
For Each MyShape In ActiveSheet.Shapes
If MyShape.Name < msoShapeDownArrow Then
MyShape.Delete
End If
Next MyShape
End Sub


--
Dave Peterson

Pete[_34_]

Delete all drawings/shapes except DownArrows
 
Thank you so much, Dave.

Been battling with it all day . . . :)

Regards,
Peter Bircher

Cell : 083 233 1628
Email:

"Dave Peterson" wrote in message
...
The .name property isn't what you want to you. The Name is the string you
see in the namebox (to the left of the formulabar).

I'd try:

Option Explicit
Sub DeleteShapesExceptDownArrows()
Dim MyShape As Shape
For Each MyShape In ActiveSheet.Shapes
If MyShape.AutoShapeType < msoShapeDownArrow Then
MyShape.Delete
End If
Next MyShape
End Sub

On 02/23/2011 03:53, Pete wrote:

Sub DeleteShapesExceptDownArrows()
Dim MyShape As Object
For Each MyShape In ActiveSheet.Shapes
If MyShape.Name < msoShapeDownArrow Then
MyShape.Delete
End If
Next MyShape
End Sub


--
Dave Peterson




All times are GMT +1. The time now is 12:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com