Chart Title Reverts Back To Previous Value

  • Thread starter Pete at Sappi Fine Paper
  • Start date
P

Pete at Sappi Fine Paper

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!
 
P

Pete at Sappi Fine Paper

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

paul.robinson

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
 
P

Pete at Sappi Fine Paper

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top