Erasing a picture by its number

ChuckDrago

Active Member
Joined
Sep 7, 2007
Messages
470
Office Version
  1. 2010
Platform
  1. Windows
Hi All,
Is there a way to get the picture number of a picture previously inserted in a worksheet so that I can erase it by selecting "Picture" & x, the latter being the suffix number of said pix?
Thanks,
Chuck
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
By name:

Code:
  Worksheets(1).Pictures("Picture 1").Delete

By index:

Code:
  Worksheets(1).Pictures(1).Delete
 
Upvote 0
By name:

Code:
  Worksheets(1).Pictures("Picture 1").Delete

By index:

Code:
  Worksheets(1).Pictures(1).Delete

shg, not clear as to how to use that. An example: assume I have inserted a Stop sign as picture 1 and picture 2 is a Go sign, to serve as my master copies. The application will define whether a situation is a Go or a Stop. To reflect that, I will copy the corresponding picture to a certain location. The copied picture will be assigned "Picture x" labels, with x being a growing number.
When the application makes another Stop/Go decision, I want to delete the previously copied pix before copying the new one. How do I get the value of x? Or the index number?
Thank you,
Chuck
 
Upvote 0
You can get the name after you copy it:

Code:
  With Worksheets(1)
    .Pictures(1).Copy
    .Range("A1").PasteSpecial
    myPic = .Pictures(.Pictures.Count).Name
  End With
 
Last edited:
Upvote 0
You can get the name after you copy it:

Code:
  With Worksheets(1)
    .Pictures(1).Copy
    .Range("A1").PasteSpecial
    myPic = .Pictures(.Pictures.Count).Name
  End With

Aha! That is exactly what I was looking for. Thank you shg.
Chuck
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top