Solved

Modify DeleteFunction

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Getting error in connectionstring with Excel. 30 35
Excel VBA get Access table names with ADO 2 21
VLOOKUP 6 18
Excel error  #DIV/0! 7 19
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel 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…

831 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