Conditional Pie Chart Formatting (Color)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I have a pie chart with a 150 or so slices (based upon data in Column A). Looking for a way to make the color of each of the slices 1 of 4 possibilities depending upon which of the 4 possible values (in my case 4 company divisions) is listed in Column B. I can change each slice's color one at a time, but this is too time consuming since I have so many. Thanks in advance to anyone who might be able to assist
 
Is it possible to add more columns... if so then you can
format the data series according to the 4 company
divisions... just put each company division's data into
its own column and wam... you've got it.
-----Original Message-----
Hello,

I have a pie chart with a 150 or so slices (based upon
data in Column A). Looking for a way to make the color
of each of the slices 1 of 4 possibilities depending upon
which of the 4 possible values (in my case 4 company
divisions) is listed in Column B. I can change each
slice's color one at a time, but this is too time
consuming since I have so many. Thanks in advance to
anyone who might be able to assist.
 
I don't think KB noticed you were working with a Pie chart.

Here's the kind of macro you need. The X values of the plotted series is
the column of division names, and the Y values are the pie wedge sizes.
In the code below, change the dummy labels "AAAA" etc to your division
labels, and change the ColorIndex values to the colors you want.

Sub ColorWedges()
Dim iPoint As Long, nPoint As Long
With ActiveChart.SeriesCollection(1)
For iPoint = 1 To .Points.Count
Select Case WorksheetFunction.Index(.XValues, iPoint)
Case "AAAA"
.Points(iPoint).Interior.ColorIndex = 6 ' Yellow
Case "BBBB"
.Points(iPoint).Interior.ColorIndex = 5 ' Blue
Case "CCCC"
.Points(iPoint).Interior.ColorIndex = 3 ' Red
Case "DDDD"
.Points(iPoint).Interior.ColorIndex = 13 ' Purple
Case "EEEE"
.Points(iPoint).Interior.ColorIndex = 46 ' Orange
Case "FFFF"
.Points(iPoint).Interior.ColorIndex = 4 ' Green
Case "GGGG"
.Points(iPoint).Interior.ColorIndex = 8 ' Cyan
End Select
Next
End With
End Sub

- Jon
 
Jon, thanks for the advice. However, I've never used macros. Might you have any reference suggestions?
 
Back
Top