Hi,
I have seen many posts about changing a chart's point or points based on values of the X axis but I have a different issue:
I want to color code the X axis labels based on either the label itself (a text, not a number) or a cell I can look up.
I can get to the XValue label itself using the .SeriesCollection.XValues (index) and thus can do a test
But I cannot find a way to set the label color. I saw something about using .Datalabels.Font.Color but that fails (cannot find the count property of the DataLabels class, and when I add an index to DataLabels, I get the same error
I use Excel 2010.
Code is below
Dim SRS As Series
Dim vtest As Variant
With chtYield
' vntAxisLabels = .SeriesCollection(1).XValues
lngPoint = 1
For Each SRS In .SeriesCollection
'SRS.ApplyDataLabels AutoText:=True, LegendKey:= _
'False, ShowSeriesName:=False, ShowCategoryName:=False, ShowValue:=True, _
'ShowPercentage:=False, ShowBubbleSize:=False
vtest = SRS.XValues(lngPoint)
If Right(SRS.XValues(lngPoint), 2) = "SN" Then
SRS.DataLabels(lngPoint).Font.ColorIndex = 5
Else
SRS.DataLabels.Font.ColorIndex = 3
End If
Next SRS
End With
I cannot just change the color of the bar because one of my charts is a stacked-bar charts with multiple colors already. Changing the x-axis label color is the best visual method I can think of
Thanks in advance
Olivier
Bookmarks