[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2013-01-31
3
Medium Priority
?
383 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 400 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 1600 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
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.

656 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