Solved

Modify DeleteFunction

Posted on 2014-01-21
2
121 Views
Last Modified: 2014-01-21
I have this delete function below.  However I need to make an exception.  I need to keep the shape called Picture 1, how would i modify this to do that

Function DeletePictures()

   Dim TargetShape As Shape
   Sheet20.Select
   If ActiveSheet.Type <> xlWorksheet Then Exit Function
   
   For Each TargetShape In ActiveSheet.Shapes
      If TypeOf TargetShape.DrawingObject Is Picture Then TargetShape.Delete
   Next TargetShape

End Function
0
Comment
Question by:sandramac
2 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 39798971
You can do it like this.
Function DeletePictures()
Dim TargetShape As Shape


   If Sheet20.Type <> xlWorksheet Then Exit Function
   
   For Each TargetShape In Sheet20.Shapes
      If TypeOf TargetShape.DrawingObject Is Picture And TargetShape.Name <> "Picture 1" Then 
          TargetShape.Delete
     End If
   Next TargetShape

End Function 

Open in new window

0
 

Author Closing Comment

by:sandramac
ID: 39798975
Perfect, thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now