Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Modify DeleteFunction

Posted on 2014-01-21
2
Medium Priority
?
131 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 35

Accepted Solution

by:
Norie earned 2000 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

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

876 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