Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Dec 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Colors in charts

    I'm using Excel 2010 and have been using colors in my charts. My management team likes to sort the data and when the data is sorted, all my pretty color work goes away. I'm using black for Black Belt books, Yellow for Yellow Belt and Green for Green Belt....
    Is there a way to lock the colors to a specific piece of data?

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    The colours are locked to the series order, so when you sort, the colours will change. You would have to use code to update the colours - which may or may not be complicated, depending on how easily the code can assign colour based on the data.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,633
    Thanks
    115
    Thanked 647 Times in 590 Posts
    JASRF,

    Something like this should do the trick to quickly return the colors:

    Code:
    Sub ChangeSeriesColor()
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.SeriesCollection(1).Format.Line.ForeColor.RGB = vbBlack
        ActiveChart.SeriesCollection(2).Format.Line.ForeColor.RGB = vbYellow
        ActiveChart.SeriesCollection(3).Format.Line.ForeColor.RGB = vbGreen
    End Sub
    To run the macro, click Alt-F8 > Select ChangeSeriesColor > click Run

    HTH,
    Maud

Posting Permissions

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