Solved

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

Posted on 2013-01-31
3
363 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
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

860 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