snowman1976
Board Regular
- Joined
- Nov 4, 2008
- Messages
- 191
Hello
I have this piece of code that works quite well, it changes the color of the bars based on the values. I now will have many graphs in the same sheet that I want to apply this to. How do I change it so its looking at not just 'mainchart', but instead does it to all the graphs ?
Dim chartIterator As Integer, pointIterator As Integer, _
seriesArray() As Variant
'For chartIterator = 1 To ActiveSheet.ChartObjects.Count
seriesArray = ActiveWorkbook.Sheets("GRAPHS").ChartObjects("MAINCHART"). _
Chart.SeriesCollection(1).Values
For pointIterator = 1 To UBound(seriesArray)
If seriesArray(pointIterator) < 0.95 Then
ActiveWorkbook.Sheets("GRAPHS").ChartObjects("MAINCHART"). _
Chart.SeriesCollection(1).Points(pointIterator).Interior.Color = _
RGB(255, 0, 0)
Else
If seriesArray(pointIterator) < 1 Then
ActiveWorkbook.Sheets("GRAPHS").ChartObjects("MAINCHART"). _
Chart.SeriesCollection(1).Points(pointIterator).Interior.Color = _
RGB(255, 255, 0)
Else
ActiveWorkbook.Sheets("GRAPHS").ChartObjects("MAINCHART"). _
Chart.SeriesCollection(1).Points(pointIterator).Interior.Color = _
RGB(0, 176, 80)
End If
End If
Next pointIterator
I have this piece of code that works quite well, it changes the color of the bars based on the values. I now will have many graphs in the same sheet that I want to apply this to. How do I change it so its looking at not just 'mainchart', but instead does it to all the graphs ?
Dim chartIterator As Integer, pointIterator As Integer, _
seriesArray() As Variant
'For chartIterator = 1 To ActiveSheet.ChartObjects.Count
seriesArray = ActiveWorkbook.Sheets("GRAPHS").ChartObjects("MAINCHART"). _
Chart.SeriesCollection(1).Values
For pointIterator = 1 To UBound(seriesArray)
If seriesArray(pointIterator) < 0.95 Then
ActiveWorkbook.Sheets("GRAPHS").ChartObjects("MAINCHART"). _
Chart.SeriesCollection(1).Points(pointIterator).Interior.Color = _
RGB(255, 0, 0)
Else
If seriesArray(pointIterator) < 1 Then
ActiveWorkbook.Sheets("GRAPHS").ChartObjects("MAINCHART"). _
Chart.SeriesCollection(1).Points(pointIterator).Interior.Color = _
RGB(255, 255, 0)
Else
ActiveWorkbook.Sheets("GRAPHS").ChartObjects("MAINCHART"). _
Chart.SeriesCollection(1).Points(pointIterator).Interior.Color = _
RGB(0, 176, 80)
End If
End If
Next pointIterator