Solved

Modify DeleteFunction

Posted on 2014-01-21
2
127 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
[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 Comments
 
LVL 34

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
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 will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
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…

707 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