VBA Code - Rename copied shape

Spaztic

New Member
Joined
Jul 27, 2023
Messages
48
Office Version
  1. 365
Platform
  1. Windows
Anyone know how I can rename the copied/pasted 'Arrow' to 'Arrow2'? As the code is written now, the 'Arrow' gets copied and the new shape is named 'Arrow' as well. I want it to be named 'Arrow2'

The way this works is I have an arrow shape that you click(macro) and it copies that arrow and pastes it into the selected cell at a certain position. It also formats the arrow to be a different color and applies a glow to it.

This code seems to work intermittently right now and I'm trying to figure out why. So, I'm trying what I described above first.

VBA Code:
Sub Arrow()
    Dim Sh As Shape
   
    With ActiveSheet
        .Shapes("Arrow").Copy
        .Paste 'inital position at selected cell
        Set Sh = .Shapes(.Shapes.Count) 'the newest shape
    End With
      
    With Sh
        'Set position
        .Top = ActiveCell.Top
        .Left = ActiveCell.Left
       
        'fine tune position
        .IncrementLeft 10
        .IncrementTop 10
       
         .OnAction = ""
         
        With .Line
            .ForeColor.RGB = RGB(192, 0, 0)
            .Weight = 2.5
        End With
       
        With .Glow
            .Color.ObjectThemeColor = msoThemeColorBackground1
            .Radius = 3
        End With
    End With
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
VBA Code:
With Sh
        Sh.Name = "Arrow2"
        'Set position
...... the rest of Yor code
 
Upvote 0
Solution

Forum statistics

Threads
1,223,931
Messages
6,175,465
Members
452,646
Latest member
tudou

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