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).
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Select the chart, then on the Layout tab in the Chart Tools group, rename it using the box on the right hand side.
 
Upvote 0
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
 
Upvote 0
I don't know what to say - it works for me.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,208
Members
448,554
Latest member
Gleisner2

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