Solved

Excel replace?  or VBA? - How to delete randomly placed graphic objects

Posted on 2013-01-31
3
367 Views
Last Modified: 2013-02-06
I received this worksheet and it has randomly placed tiny graphic elements.  How can I get rid of this using find/replace and/or VBA (see graphic)
err
0
Comment
Question by:brothertruffle880
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Assisted Solution

by:Shanan212
Shanan212 earned 100 total points
ID: 38840798
Try this

Sub Deleteall()

ActiveWorksheet.Shapes.SelectAll 
Selection.Delete 

End sub

Open in new window

0
 
LVL 26

Accepted Solution

by:
redmondb earned 400 total points
ID: 38840813
Hi, brothertruffle880.

This is a problem I've dealt with here a number of times. The code below will delete all Shapes on the active sheet (there's a warning at the start).

Edit: Just seen your post, Shanan212. Yours is a vastly better solution - as long as there aren't tens of thousands of objects when an attempt to delete them all tends to crash Excel.

Regards,
Brian.
Sub Delete_All_Shapes()
Dim xResponse As Long
Dim xShape    As Shape

If ActiveSheet.Shapes.count = 0 Then
    MsgBox ("No Shapes in the current sheet. Run cancelled.")
    Exit Sub
End If

xResponse = MsgBox("About to delete all of the current sheet's Shapes. [" & ActiveSheet.Shapes.count & "]" & Chr(10) _
                                & "('OK' to continue, 'Cancel' to quit.)", vbOKCancel, "Delete All Shapes")
If xResponse = 2 Then Exit Sub

For Each xShape In ActiveSheet.Shapes

    xShape.Delete
    
Next

End Sub

Open in new window

0
 
LVL 26

Expert Comment

by:redmondb
ID: 38860290
Thanks, brothertruffle880.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question