# VBA Excel Shape names (really deleting the name)



## YungPrg (May 3, 2006)

How do I rename a shape object? Here's the skinny.  Let's say I have three Rectangle shape objects on sheet1 which I have added.   Each having a text name of shape1 shape2 & shape3.    I believe Excel uses a different naming scheme like ... Rectangle 1, Rectangle2 & Rectangle 3.  
When I programically delete the shapes, I have to reference the shape names as Rectangle 1,2 or 3 which works!  I see the shape deleted.  However, If I create three more shape of the same type(rectangle) and want to delete them, I can no longer reference them as Rectangle 1,2 or 3.   I have to use Rectangle 4,5 or 6.   This leads me to believe that I only graphically deleted the shapes but not the shape names from Excel's shape name counter(or what ever is keeping count of the number of shape(types) created).     So more specifically, how do I programatically delete a shape name such that when I create another shape object of the same type, Excel begins to count it as... the let's say for example, Rectangle 1 again.?  Any ideas anyone?


----------



## Damon Ostrander (May 3, 2006)

Hi YungPrg,

Good question!  I don't know how to reset the automatic naming counter, but I'm wondering if you are aware that you can manually rename any shape by typing the name in the Name box above cell A1 (same place you would name a cell range)?  

And of course you can also rename shapes in VBA, so you could write a macro that would look for missing names in a sequence and fill the gaps--like renaming Rectangles 4,5,6 to Rectangles 1,2,3. 

Damon


----------



## doco (May 4, 2006)

Also, in order to rename a chart you must hold the CTRL key then select the chart in order to activate the name box.


----------

