Reseting an array

JDeiley

New Member
Joined
Sep 1, 2010
Messages
20
Good day all,

I have a question for you. When I do an insert screenshot command in Excel 2010 it names the picture as follows:

ActiveSheet.Shapes.Range(Array("Picture 1"))

If I delete that picture and do another insert screenshot command it names the picture as follows:

ActiveSheet.Shapes.Range(Array("Picture 2"))

What I need to do is reset that array back to "Picture 1" every time my macro goes through and deletes the array of pictures. In other words, if I insert 3 pictures and then delete them I want the next picture inserted to be "Picture 1" and not "Picture 4".

Is there a simple way to do this? I know little to nothing about arrays and would be grateful for your help.

Thank you all for your help!

JDeiley
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I don't know of a way to reset the picture numbering convention. That doesn't mean it can't be done. I just don't know how.

This will loop through all the pictures on a sheet and re-number them starting from Picture 1. They will be numbered in the order they were created.

Code:
    Dim pic As Object, counter As Long
    
    For Each pic In ActiveSheet.Pictures
        counter = counter + 1
        ' Give each a temp name to prevent overlap with any existing pictures
        pic.Name = "TempPicName " & counter
    Next pic
    counter = 0
    For Each pic In ActiveSheet.Pictures
        counter = counter + 1
        pic.Name = "Picture " & counter
    Next pic
 
Upvote 0
I presume that you are inserting a picture later on in the code. When you insert the picture, you can give it any name you want, unless that name is in use.
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,949
Latest member
Dupuhini

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