I would like to change the colour of waterfall chart based on chart value.
For example, if the value negative, put red colour. If value is positive, put green colour.
I got below code from excel vba changing bar chart color for a data point based on point value
This code works with bar chart. However, I cannot use it with waterfall as it shown error "Object doesn't support this action"
Does anyone know how to config this to use with waterfall? Any suggestion would be highly appreciated!
Thanks,
Sub color_chart()
Dim chartIterator As Integer, pointIterator As Integer, _
seriesArray() As Variant
For chartIterator = 1 To ActiveSheet.ChartObjects.Count
seriesArray = ActiveWorkbook.Sheets("Sheet1").ChartObjects(chartIterator). _
chart.SeriesCollection(1).Values
For pointIterator = 1 To UBound(seriesArray)
If seriesArray(pointIterator) >= 0 Then
ActiveWorkbook.Sheets("Sheet1").ChartObjects(chartIterator). _
chart.SeriesCollection(1).Points(pointIterator).Interior.Color = _
RGB(146, 208, 80)
Else
ActiveWorkbook.Sheets("Sheet1").ChartObjects(chartIterator). _
chart.SeriesCollection(1).Points(pointIterator).Interior.Color = _
RGB(255, 0, 0)
End If
Next pointIterator
Next chartIterator
End Sub