ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Chart Title Reverts Back To Previous Value (https://www.excelbanter.com/excel-programming/401420-chart-title-reverts-back-previous-value.html)

Pete at Sappi Fine Paper

Chart Title Reverts Back To Previous Value
 
I have a chart showing delivery performance for a truck carrier. The chart
is updated by means of a program, which pulls in data based on what carrier
has been selected in another tab. It all works fine except for one thing:
the chart title, having been set by a line in the code, reverts back to the
original title as soon as another chart or cell is selected.

To begin with, the chart title is "Carrier1 On Time Performance".

My code then says:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartTitle.Select
Selection.Font.Size = 8
Selection.Characters.Text = "Carrier2 On Time Performance"
Range("A1").Select

When I run this code, I see the chart title briefly change to "Carrier2 On
Time Performance", but as soon as cell A1 is selected, it changes back to
"Carrier1 On Time Performance".

Any idea why this is happening? It is driving me crazy. Charts 2 and 3
have similar titles and code, but they do not have this problem. Once the
program is run, charts 2 and 3 show Carrier2, but chart 1 still shows
Carrier1. If I go into the title manually and change it to Carrier2, the
change sticks. So why won't it stick when the code does it?

Any help you could provide would be much appreciated - thanks!

Pete at Sappi Fine Paper

Never Mind!
 
I had a identical Chart4 stacked on top of Chart1. Chart1 was updating just
fine, then slipping behind Chart4 when deselected. D'oh!

"Pete at Sappi Fine Paper" wrote:

I have a chart showing delivery performance for a truck carrier. The chart
is updated by means of a program, which pulls in data based on what carrier
has been selected in another tab. It all works fine except for one thing:
the chart title, having been set by a line in the code, reverts back to the
original title as soon as another chart or cell is selected.

To begin with, the chart title is "Carrier1 On Time Performance".

My code then says:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartTitle.Select
Selection.Font.Size = 8
Selection.Characters.Text = "Carrier2 On Time Performance"
Range("A1").Select

When I run this code, I see the chart title briefly change to "Carrier2 On
Time Performance", but as soon as cell A1 is selected, it changes back to
"Carrier1 On Time Performance".

Any idea why this is happening? It is driving me crazy. Charts 2 and 3
have similar titles and code, but they do not have this problem. Once the
program is run, charts 2 and 3 show Carrier2, but chart 1 still shows
Carrier1. If I go into the title manually and change it to Carrier2, the
change sticks. So why won't it stick when the code does it?

Any help you could provide would be much appreciated - thanks!


[email protected]

Chart Title Reverts Back To Previous Value
 
On Nov 20, 3:05 pm, Pete at Sappi Fine Paper
wrote:
I have a chart showing delivery performance for a truck carrier. The chart
is updated by means of a program, which pulls in data based on what carrier
has been selected in another tab. It all works fine except for one thing:
the chart title, having been set by a line in the code, reverts back to the
original title as soon as another chart or cell is selected.

To begin with, the chart title is "Carrier1 On Time Performance".

My code then says:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartTitle.Select
Selection.Font.Size = 8
Selection.Characters.Text = "Carrier2 On Time Performance"
Range("A1").Select

When I run this code, I see the chart title briefly change to "Carrier2 On
Time Performance", but as soon as cell A1 is selected, it changes back to
"Carrier1 On Time Performance".

Any idea why this is happening? It is driving me crazy. Charts 2 and 3
have similar titles and code, but they do not have this problem. Once the
program is run, charts 2 and 3 show Carrier2, but chart 1 still shows
Carrier1. If I go into the title manually and change it to Carrier2, the
change sticks. So why won't it stick when the code does it?

Any help you could provide would be much appreciated - thanks!


Hi
Try this (untested)

ActiveSheet.ChartObjects("Chart 1").Activate
With ActiveChart.Chart.ChartTitle
.Font.Size = 8
.Text = "Carrier2 On Time Performance"
End with
Range("A1").Select

I think the ActiveChart is a chart object which contains the chart.

regards
Paul


Pete at Sappi Fine Paper

Chart Title Reverts Back To Previous Value
 
Thanks Paul - I appreciate your response. I'm all set now, though - I had a
Chart4 sitting on top of Chart1 and this was confusing the issue.

" wrote:

On Nov 20, 3:05 pm, Pete at Sappi Fine Paper
wrote:
I have a chart showing delivery performance for a truck carrier. The chart
is updated by means of a program, which pulls in data based on what carrier
has been selected in another tab. It all works fine except for one thing:
the chart title, having been set by a line in the code, reverts back to the
original title as soon as another chart or cell is selected.

To begin with, the chart title is "Carrier1 On Time Performance".

My code then says:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartTitle.Select
Selection.Font.Size = 8
Selection.Characters.Text = "Carrier2 On Time Performance"
Range("A1").Select

When I run this code, I see the chart title briefly change to "Carrier2 On
Time Performance", but as soon as cell A1 is selected, it changes back to
"Carrier1 On Time Performance".

Any idea why this is happening? It is driving me crazy. Charts 2 and 3
have similar titles and code, but they do not have this problem. Once the
program is run, charts 2 and 3 show Carrier2, but chart 1 still shows
Carrier1. If I go into the title manually and change it to Carrier2, the
change sticks. So why won't it stick when the code does it?

Any help you could provide would be much appreciated - thanks!


Hi
Try this (untested)

ActiveSheet.ChartObjects("Chart 1").Activate
With ActiveChart.Chart.ChartTitle
.Font.Size = 8
.Text = "Carrier2 On Time Performance"
End with
Range("A1").Select

I think the ActiveChart is a chart object which contains the chart.

regards
Paul




All times are GMT +1. The time now is 07:12 PM.

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