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, Shape.name (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?

Thanks
Kelvin
Kelvin4Asked:
Who is Participating?
 
Rgonzo1971Commented:
Hi,

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
Next
End Sub

Open in new window

Regards
0
 
Kelvin4Author Commented:
Thanks, Rgonzo:
I'll work on this by tomorrow
Kelvin
0
 
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.
0
 
Kelvin4Author Commented:
Thanks for rapidly and completely solving my question, and for taking the trouble to expand my knowledge.
Regards, Kelvin
0
 
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
0
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.