Rename all shapes in active sheet

haseft

Active Member
Joined
Jun 10, 2014
Messages
321
Hi!

In Worksheet1 I have a lot of shapes, some has same name.
I want to rename all shapes in Worksheet1 to: Picture1, Picture2, Picture3, Picture4, ..... and so on.
Please help.

HTML:
Function ShapeAtActiveCell() As String
Dim Sh As Shape

For Each Sh In ActiveSheet.Shapes
    If Sh.TopLeftCell.Address = ActiveCell.Address Then
       ShapeAtActiveCell = Sh.Name
       ActiveSheet.Shapes(ShapeAtActiveCell).Select
       Exit Function
    End If
Next
End Function

'--------------

Sub RenameShapes()
Dim p As String, n As Long
p = "Picture"
n = 1000

For i = 1 To n
   With Worksheets("Sheet1")
     .Shapes(ShapeAtActiveCell).Name = p + i
   End With
Next
End Sub
 
Last edited:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
How about
Code:
Sub RenameShapes()
Dim sh As Shape, i As Long
For Each sh In ActiveSheet.Shapes
   i = i + 1
   sh.Name = "Picture" & i
Next sh
End Sub
 
Upvote 0
Solution
Thanks Fluff!
If I undrstand, in this case there is no need use Function ShapeAtActiveCell.
Or?
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,454
Members
452,514
Latest member
cjkelly15

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