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
Solved

Modify DeleteFunction

Posted on 2014-01-21
2
124 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 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