Change color of pie chart based on values

Hi
this is my cases
For columns , and nine rows
values are range from 1-5
I want the following values to correspond to the following colors  
1-RED
2-Yellow
3-Blue
4-Light green
5-Dark Green
can it be done on Excel 2013
Bader_MEAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

byundtMechanical EngineerCommented:
Here is a sub that will apply your color scheme to all 2D pie charts on a worksheet.
Sub PieChartColors()
Dim cht As ChartObject
Dim pt As Point
Dim i As Long, j As Long, n As Long
Dim fsc As FullSeriesCollection
For Each cht In ActiveSheet.ChartObjects
    If cht.Chart.ChartType = xlPie Then
        Set fsc = cht.Chart.FullSeriesCollection
            n = fsc.Item(1).Points.Count
            For i = 1 To n
                j = fsc.Item(1).Values(i)
                Select Case j
                Case 1
                    fsc.Item(1).Points(i).Format.Fill.ForeColor.RGB = RGB(255, 0, 0)        'Red
                Case 2
                    fsc.Item(1).Points(i).Format.Fill.ForeColor.RGB = RGB(255, 255, 0)      'Yellow
                Case 3
                    fsc.Item(1).Points(i).Format.Fill.ForeColor.RGB = RGB(0, 112, 192)      'Blue
                Case 4
                    fsc.Item(1).Points(i).Format.Fill.ForeColor.RGB = RGB(146, 208, 80)     'Light green
                Case 5
                    fsc.Item(1).Points(i).Format.Fill.ForeColor.RGB = RGB(0, 176, 80)       'Dark green
                Case Else
                    fsc.Item(1).Points(i).Format.Fill.ForeColor.RGB = RGB(255, 255, 255)    'White
                End Select
            Next
    End If
Next
End Sub

Open in new window

PieChartColorsQ28736725.xlsm

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bader_MEAuthor Commented:
Hi
it worked, thanks
Bader_MEAuthor Commented:
like magic !!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.