How do I get the HEX or RGB numbers for the colours used in Excel Chart Style 2


I wish to get the HEX or RBG numbers for the colours that are used in the Excel 2007's chart style 2.

This is the chart style as shown in the sample sheet below.  I have used the macro recorder but that just applies activechart.chartstyle = 2

I am really only interested in the colour of the different data series shown on the example.  Green, Blue, Purple and Red etc.

LVL 17
Who is Participating?
Rory ArchibaldCommented:
OK - for example:
Sub GetRGB()
    Dim n As Long
    With ActiveChart.SeriesCollection
        For n = 1 To .Count
            Debug.Print .Item(n).Border.Color
        Next n
    End With
End Sub

Open in new window

this will output the values to the Immediate Window in the VBE. (you need to select the chart first)
Rory ArchibaldCommented:
Do you actually need the individual R, G and B component values, or just the overall RGB number?
wobbledAuthor Commented:
The overall RBG should be fine

I'm trying to recreate charts in WPF using a similar style to that available in Excel so I can work with any colour codes that Microsoft accepts
kgerbChief EngineerCommented:
Whenever I need to get RGB values for something I use Pixie.  It works well.

wobbledAuthor Commented:
Thanks - did the job fine
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.