Option Explicit
Sub SetPieChartColorsBySliceName()
Dim lX As Long
Dim arySeriesData, aryPointsNameLocation, aryPointNames
Dim namesWorksheet As String
Dim namesRange As String
With ActiveSheet.ChartObjects(1).Chart
If .Type <> 5 Then
MsgBox "The first chart on this worksheet is not a Pie Chart."
GoTo End_Sub
End If
arySeriesData = Split(ActiveSheet.ChartObjects(1).Chart.SeriesCollection(1).formula, ",")
aryPointsNameLocation = Split(arySeriesData(1), "!")
namesWorksheet = aryPointsNameLocation(0)
namesRange = aryPointsNameLocation(1)
aryPointNames = Worksheets(namesWorksheet).Range(namesRange)
For lX = LBound(aryPointNames, 1) To UBound(aryPointNames, 1)
.SeriesCollection(1).Points(lX).Select
Select Case aryPointNames(lX, 1)
Case "Lost"
Selection.Format.Fill.ForeColor.RGB = RGB(255, 100, 0)
Case "Found"
Selection.Format.Fill.ForeColor.RGB = RGB(100, 255, 0)
Case "Obsolete"
Selection.Format.Fill.ForeColor.RGB = RGB(100, 0, 255)
Case Else
Selection.Format.Fill.ForeColor.RGB = RGB(0, 0, 0)
End Select
Next
End With
End_Sub:
End Sub