An excel cell 'contains' a jpg shape. When I duplicate that cell how do I get the shape name for the newly duplicated shape?

My Worksheet contains a row of cells in which different shapes have been added to some (not all)  specific columns. (Their purpose is that clicking each shape provides access to different vba procedures).

Some cells in the row contain comments, but cells with an added shapes do NOT contain comments

Shapes are added via excel Shapes.AddPicture Method

When a Shape is added to a cell, (eg 'Picture16') is recorded to enable control of visibility, and shape deletion.

Now I copy the row of shapes to a new row on the same sheet. How do I enumerate the shapes collection to obtain the shape.names for each identified cell that contains a newly copied shape?

Who is Participating?

pls try

Sub Macro()
Set newRow = Range("4:4")
For Each shp In ActiveSheet.Shapes
    If Not Intersect(newRow, shp.TopLeftCell) Is Nothing Then
        MsgBox shp.Name
    End If
End Sub

Open in new window

Kelvin4Author Commented:
Thanks, Rgonzo:
I'll work on this by tomorrow
Martin LissOlder than dirtCommented:
If you are interested in the name of the last shape added you don't need to iterate through them but rather just do something like LastShapeName = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name.
Kelvin4Author Commented:
Thanks for rapidly and completely solving my question, and for taking the trouble to expand my knowledge.
Regards, Kelvin
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.