ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I name an autoshape so that I can refer to it in a macro? (https://www.excelbanter.com/excel-programming/411627-how-do-i-name-autoshape-so-i-can-refer-macro.html)

stacy

How do I name an autoshape so that I can refer to it in a macro?
 
I'm trying to create a macro that changes the color of different autoshapes
depending on the values of certain cells. Each autoshape would change,
depending on the value of a different cell. So, I need to refer to each
autoshape separately. When I recorded the macro, it refers to "Rectangle
220" for every rectangle, so when I run it, it only changes the first
rectangle to the correct color.

Don Guillett

How do I name an autoshape so that I can refer to it in a macro?
 
One way. Select the shape and look in the NAME box to the left of the
formula box. Change the name there.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Stacy" wrote in message
...
I'm trying to create a macro that changes the color of different
autoshapes
depending on the values of certain cells. Each autoshape would change,
depending on the value of a different cell. So, I need to refer to each
autoshape separately. When I recorded the macro, it refers to "Rectangle
220" for every rectangle, so when I run it, it only changes the first
rectangle to the correct color.



Gary''s Student

How do I name an autoshape so that I can refer to it in a macro?
 
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/28/2008 by James Ravenswood
'

'
ActiveSheet.Shapes.AddShape(msoShapeOval, 204#, 135.75, 57.75,
61.5).Select
ActiveSheet.Shapes(1).Name = "stacy"
Range("A1").Select
End Sub

--
Gary''s Student - gsnu200789

Dave Peterson

How do I name an autoshape so that I can refer to it in a macro?
 
If you've already added the shapes, you can select them (one at a time) and
change their name in the namebox -- to the left of the formulabar.

Remember to hit enter when you've finished typing the new name.

Stacy wrote:

I'm trying to create a macro that changes the color of different autoshapes
depending on the values of certain cells. Each autoshape would change,
depending on the value of a different cell. So, I need to refer to each
autoshape separately. When I recorded the macro, it refers to "Rectangle
220" for every rectangle, so when I run it, it only changes the first
rectangle to the correct color.


--

Dave Peterson


All times are GMT +1. The time now is 05:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com