mikelowski
New Member
I want to color a chart depending on range values. From 0 to 29.949 one color, from 29.950 to 39.950 another one, and so on. Here's the code I've come up with, but it doesn't work so far, it just colors all columns with the last Else argument.
Code:
Sub ColorChartMacro()
Dim i As Long
For i = 1 To ActiveChart.SeriesCollection.Count
With ActiveChart.SeriesCollection(i)
If WorksheetFunction.Sum(.Values) < 29.949 Then
.Interior.Color = RGB(217, 0, 0)
ElseIf WorksheetFunction.Sum(.Values) < 39.949 Then
.Interior.Color = RGB(255, 102, 0)
ElseIf WorksheetFunction.Sum(.Values) < 59.949 Then
.Interior.Color = RGB(255, 204, 0)
ElseIf WorksheetFunction.Sum(.Values) < 69.949 Then
.Interior.Color = RGB(153, 204, 0)
Else
.Interior.Color = RGB(0, 128, 0)
End If
End With
Next
End Sub
Last edited: