Hey I have the following VBA which graphs my positive values as green and negative as red. I need to put the negative values back above the axis, any idea how to accomplish that?
Sub FormatPointByCategoryAndValue()
Dim rColor As Range
Dim vColor As Variant
Dim srsColor As Series
Dim srsColor2 As Series
Dim iRow As Long
Dim iCol As Long
Dim iPoint As Long
Dim vCategories As Variant
Dim vValues As Variant
Const sColorSheetName As String = "ColorSheet"
Const sColorRangeName As String = "ColorRange"
PosCol = RGB(0, 0, 255) ' colour for positive values
NegCol = RGB(255, 0, 0) ' colour for negative values
Set srsColor = ActiveChart.SeriesCollection(1)
' cycle through points
For iPoint = 1 To Sheet2.Range("Start_Series").End(xlDown).Row - Sheet2.Range("Start_Series").Row + 1
'Extract the column number iPoint
Set srsColor2 = ActiveChart.SeriesCollection(iPoint)
With srsColor2
vValues = .Values
End With
For iCol = 1 To srsColor.Points.Count
If vValues(iCol) < 0 Then
ActiveChart.SeriesCollection(iPoint).Points(iCol).Select
Selection.Format.Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf vValues(iCol) > 0 Then
ActiveChart.SeriesCollection(iPoint).Points(iCol).Select
Selection.Format.Fill.ForeColor.RGB = RGB(0, 176, 80)
Else
ActiveChart.SeriesCollection(iPoint).Points(iCol).Select
Selection.Format.Fill.ForeColor.RGB = RGB(255, 255, 255)
End If
Next iCol
Next iPoint
ExitHere:
End Sub
Also attached the graph as a picture so you can see what I'm talking about
Bookmarks