F
frogman7
I have 12 charts 1 for each person and the data changes every week and
some of the values have 0 so are filtered out. On the chart I want
0-15 to be blue, 16-30 to be light purple, 31-60 to be a cream color,
61-90 to be light blue, and 90+ to be dark purple. With the code
below I can change the color if I take the if statement out but I
would like to change the color based on the label. I have tried
several things like .text, .name, and .label. I just can't fine the
right name.
Name1
0-15 1
61-90 1
90+ 3
Name 2
0-15 14
16-30 5
31-60 1
61-90 6
90+ 12
For i = 1 To ActiveChart.Legend.LegendEntries.Count
ActiveChart.Legend.LegendEntries(i).LegendKey.Select
If ActiveChart.Legend.LegendEntries(i).Label.Text = "0-15"
Then
With Selection.Interior
ActiveChart.Legend.LegendEntries(i).LegendKey
.ColorIndex = 60
End With
End If
If ActiveChart.Legend.LegendEntries(i).Name = "16-30" Then
With Selection.Interior
.ColorIndex = 2
End With
End If
If ActiveChart.Legend.LegendEntries(i).Name = "31-60" Then
With Selection.Interior
.ColorIndex = 3
End With
End If
If ActiveChart.Legend.LegendEntries(i).Name = "61-90" Then
With Selection.Interior
.ColorIndex = 4
End With
End If
If ActiveChart.Legend.LegendEntries(i).Name = "90+" Then
With Selection.Interior
.ColorIndex = 5
End With
End If
Next i
some of the values have 0 so are filtered out. On the chart I want
0-15 to be blue, 16-30 to be light purple, 31-60 to be a cream color,
61-90 to be light blue, and 90+ to be dark purple. With the code
below I can change the color if I take the if statement out but I
would like to change the color based on the label. I have tried
several things like .text, .name, and .label. I just can't fine the
right name.
Name1
0-15 1
61-90 1
90+ 3
Name 2
0-15 14
16-30 5
31-60 1
61-90 6
90+ 12
For i = 1 To ActiveChart.Legend.LegendEntries.Count
ActiveChart.Legend.LegendEntries(i).LegendKey.Select
If ActiveChart.Legend.LegendEntries(i).Label.Text = "0-15"
Then
With Selection.Interior
ActiveChart.Legend.LegendEntries(i).LegendKey
.ColorIndex = 60
End With
End If
If ActiveChart.Legend.LegendEntries(i).Name = "16-30" Then
With Selection.Interior
.ColorIndex = 2
End With
End If
If ActiveChart.Legend.LegendEntries(i).Name = "31-60" Then
With Selection.Interior
.ColorIndex = 3
End With
End If
If ActiveChart.Legend.LegendEntries(i).Name = "61-90" Then
With Selection.Interior
.ColorIndex = 4
End With
End If
If ActiveChart.Legend.LegendEntries(i).Name = "90+" Then
With Selection.Interior
.ColorIndex = 5
End With
End If
Next i