Renaming Charts/chart objects??

MrPez

Board Regular
Joined
Jan 28, 2010
Messages
128
I've got a chart embedded in a spreadsheet that is called 'Chart 1'.

I've got some code to run and set the trendline which seems to run ok.

Code:
Dim STPChart As Chart

Set STPChart = Worksheets("Detector1_Report").ChartObjects("Chart 1").Chart

With STPChart
    blah blah blah...
However, I don't really like having charts called 'Chart 1' as I find it more difficult for other people to decipher the code. If I change the chart object using
Code:
ActiveChart.Parent.Name = "STP"
it fails on the first line above with RTE '-2147024809 (80070057): This member can only be accessed for a chart object.'

[Note, I also change the 'Chart 1' to 'STP' in the problematic line.]

Is there some other way I ought to rename the chart? Trying directly from excel doesn't work for me (Excel 2010).
 

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,121
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
Select the chart, then on the Layout tab in the Chart Tools group, rename it using the box on the right hand side.
 

MrPez

Board Regular
Joined
Jan 28, 2010
Messages
128
I swear I tried that earlier and the name wouldn't stick, but it seems to now.

Nonetheless I still get that error with
Code:
Set STPChart = Worksheets("Detector1_Report").ChartObjects("STP").Chart
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,121
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
I don't know what to say - it works for me.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,350
Messages
5,486,345
Members
407,541
Latest member
Emilybuhman

This Week's Hot Topics

Top