+ Reply to Thread
Results 1 to 1 of 1

Color coding the X axis labels in a Bar or Line chart

Hybrid View

  1. #1
    Registered User
    Join Date
    02-17-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Color coding the X axis labels in a Bar or Line chart

    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
    Last edited by jeffreybrown; 02-17-2013 at 04:36 PM. Reason: Please use code tags...Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1