Yes you just need to add the code to test the values the other way around.
Sub FormatChart()
Dim lngPoint As Long
Dim objSeries1 As Series
Dim objSeries2 As Series
With ActiveSheet.ChartObjects(1).Chart
' make both bars the same
Set objSeries1 = .SeriesCollection(1)
Set objSeries2 = .SeriesCollection(2)
objSeries1.Format.Fill.ForeColor.SchemeColor = 17
objSeries2.Format.Fill.ForeColor.SchemeColor = objSeries1.Format.Fill.ForeColor.SchemeColor
For lngPoint = 1 To .SeriesCollection(1).Points.Count
If Application.WorksheetFunction.Index(objSeries2.Values, lngPoint) < _
Application.WorksheetFunction.Index(objSeries1.Values, lngPoint) Then
' make expense Red
objSeries2.Points(lngPoint).Format.Fill.ForeColor.RGB = RGB(255, 0, 0)
End If
If Application.WorksheetFunction.Index(objSeries1.Values, lngPoint) < _
Application.WorksheetFunction.Index(objSeries2.Values, lngPoint) Then
' make expense Red
objSeries1.Points(lngPoint).Format.Fill.ForeColor.RGB = RGB(255, 0, 0)
End If
Next
End With
End Sub
Bookmarks