Assign Name to a shape

bbran19

New Member
Joined
Jan 30, 2012
Messages
49
Office Version
  1. 365
Platform
  1. Windows
I have a macro which, among other things, draws a smiley face ( :cool: ) from the Insert + Shapes menu after a positive event.

I have a reset all button to remove the data generated by the previous macro AND remove the smiley face.

However, the smiley face keeps changing name from similey face 25, then 26 and so on. So the macro cannot delete it.

I have tried renaming the face )ALT + F10) and in the NAME BAT which works temporarily until the reset macro runs. The the name of the smiley face keeps changing name.

I need a macro that will change the reference name so the shape can be deleted with a reset macro.

Any thoughts appreciated.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
This code will insert a standard smiley face at the active cell and name it 'MySmiley'.
Code:
Sub InsertSmiley()
Dim sh As Shape

    With ActiveCell
        Set sh = .Parent.Shapes.AddShape(msoShapeSmileyFace, .Left, .Top, 20, 20)
    End With
    
    sh.Name = "MySmiley"

End Sub
 
Upvote 0
This will delete all shapes that begin with the name "Smiley Face"

Code:
    Dim shp As Shape
    For Each shp In ActiveSheet.Shapes
        If shp.Name Like "Smiley Face*" Then shp.Delete
    Next shp
 
Upvote 0
Thank you AlphaFrog. That did the trick. Thankyou Norie. I have another sheet where that will work well. Your time is appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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