Multi-Color Characters on Chart Titles on Excel 2007

roc_on_the_rocks

Board Regular
Joined
Jun 6, 2009
Messages
175
Office Version
  1. 365
Platform
  1. Windows
On Excel 2003 I was able to set different colors to specific characters on charts titles using a VBA command like this:

Code:
ActiveChart.ChartTitle.Select
Selection.Characters(Start:=33, Length:=4).Font.ColorIndex = 3

This was very useful because, imagine a chart containing Temperature data plotted with red lines, I'd make the "Temperature" characters on the Y-axis red too. If "Pressure" was plotted with blue lines, I'd make its description on the Y-axis blue too.

Then our company switched to Excel 2007 those commands crashed and I had to 'comment' them.

Would someone here know how to make it work with Excel 2007?

PS.: This apply to all chart titles (X-Y axes and also main chart title).

Thanks a lot,
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi

This is an example for the chart title that you can adapt to your needs (tested in excel 2010).

Assuming I have a chart in Sheet1 called "MyChart" with a title with more than 5 characters:

Code:
Sub PaintChars()
Dim cht As Chart
Dim chtTitle As ChartTitle
Dim chars As Characters
 
Set cht = Worksheets("Sheet1").ChartObjects("MyChart").Chart
 
Set chtTitle = cht.ChartTitle
With chtTitle
    .Characters(Start:=3, Length:=2).Font.Color = vbRed
End With
End Sub
 
Upvote 0
This is great, thank you so much PGC!

It worked like a charm:

Code:
.ChartTitle.Characters(Start:=3, Length:=2).Font.Color = vbRed
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,656
Members
449,091
Latest member
peppernaut

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