Hi,
I have created a chart with 2 series. One is a sales value, the other in the target. I have charted this and want each bar to change colour depending on if it is above or below target.
I have calculated the colour indexes using an if statement in cells d2-d7. I have written this code that works a treat for the 1st bar in the series but the others don't change, how do I get this to change all bar colour on recalc.
Thanks,
Ray
Private Sub Worksheet_Calculate()
' Conditional Chart Colour Macro
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(1).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = Range("D2:D7")
.Pattern = xlSolid
End With
End Sub
I have created a chart with 2 series. One is a sales value, the other in the target. I have charted this and want each bar to change colour depending on if it is above or below target.
I have calculated the colour indexes using an if statement in cells d2-d7. I have written this code that works a treat for the 1st bar in the series but the others don't change, how do I get this to change all bar colour on recalc.
Thanks,
Ray
Private Sub Worksheet_Calculate()
' Conditional Chart Colour Macro
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(1).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = Range("D2:D7")
.Pattern = xlSolid
End With
End Sub