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

Andreas HermleTeam leaderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Roy CoxGroup Finance ManagerCommented:
Pleased to help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.