Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename Excel chart to be more descriptive 5

Status
Not open for further replies.
Jun 12, 2003
25
US
I'm sure this is really simple but I can't figure it out. I want to rename the charts in my excel sheet so that when I code in VBA it is easier to know which is which. Right now they are Chart1, Chart2, etc. To give you a better idea of what I'm trying to do: I want to rename a chart the same way I would rename a cell. Which I would do by going to Insert> Name> Define...

Thanks for any help,

Ben
 
Hi navyguysrighthandman,

If they are on a worksheet they belong to the sheet's ChartObjects collection, so there are a few ways of which this is one ..

Code:
ActiveSheet.ChartObjects("Chart 1").Name = "Fred"

Enjoy,
Tony
 
I appreciate the help. Is there no way to just name the chart from excel instead of hardcoding it in VBA?

Thanks,
Ben
 
Hi Ben,

I would be happy to be proved wrong, but there is no way I know. You can change ChartSheet names but not chart object names within sheets.

Enjoy,
Tony
 
AFAIK, Tony is correct. This is because charts are treated as pictures rather then objects now. I'm sure it could be done in '97 but it would appear that the functionality has been lost in later versions

Rgds, Geoff
Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?
Want the best answers to your questions ? faq222-2244
 
If your chart is embedded in a worksheet, do this:

1. Select any cell on the worksheet.
2. Hold down Ctrl and click the Chart object - the handles will appear as white squares.
3. Click in the Names box and type your chart's new name, e.g. "SalesForThisMonth".
4. Press Enter.

The Chart Object is now known as "SalesForThisMonth" and you can reference it in VBA. [wink]

Cheers,

Chris
 
Beautiful stuff Chris - have a star.

Rgds, Geoff
Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?
Want the best answers to your questions ? faq222-2244
 
Great stuff Chris! [twothumbsup]

How about a faq?



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top