• Status: Solved
  • Priority: High
  • Security: Public
  • Views: 31
  • Last Modified:

Delete certain graphic from all worksheets of the current workbook

Dear Experts:

below code is supposed to delete all shapes named "Arrow_75" from all worksheets of the currently active workbook.

Regrettably nothing happens. What is wrong with this code?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

Sub DeleteCertainShapes()
Dim shp As Shape, ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
  For Each shp In ws.Shapes
     If shp.Name Like "Arrow_75" Then
     shp.Delete
  End If
  Next
Next

End Sub

Open in new window

0
Andreas Hermle
Asked:
Andreas Hermle
  • 2
1 Solution
 
Saqib Husain, SyedEngineerCommented:
Have you tried = instead of Like?
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Please try...

If shp.Name Like "Arrow_75*" Then

Open in new window

0
 
Roy CoxGroup Finance ManagerCommented:
Do you have more than one shape with that name per sheet?

delete all shapes named "Arrow_75"
, if that is the actual name then you don't need Like

Sub DeleteCertainShapes()
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
''/// assumes only one shape with this name per sheet
        ws.Shapes("Arrow_75").Delete
    Next ws
End Sub

Open in new window

0
 
Roy CoxGroup Finance ManagerCommented:
Pleased to help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now