Link to home
Start Free TrialLog in
Avatar of gtgloner
gtglonerFlag for Canada

asked on

Change colour of data point in bar chart based on value in spreadsheet table

I have been asked to create a bar chart which has one of the data points in the chart change colour from green to red based on the value of the data point, specifically, if the point is less than or equal to 57990, the colour of the point should be green, if greater than 57990, it should change to red. Here is the code I have (which doesn't work!):

Private Sub Chart_Activate()

  If ActiveChart.SeriesCollection(1).Points(3).Value < 57990 Then
 
    ActiveChart.SeriesCollection(1).Points(3).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 4
        .Pattern = xlSolid
    End With
   
    Else
   
    ActiveChart.SeriesCollection(1).Points(3).Select
    With Selection.Border
        .Weight = xlThin
        .LineStyle = xlAutomatic
    End With
    Selection.Shadow = False
    Selection.InvertIfNegative = False
    With Selection.Interior
        .ColorIndex = 7 'not sure if this is the right code for red
        .Pattern = xlSolid
    End With
  End If
   
End Sub

Thanx in advance
ASKER CERTIFIED SOLUTION
Avatar of [ fanpages ]
[ fanpages ]

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gtgloner

ASKER

That's the ticket!!! Nice going, fanpages
Avatar of [ fanpages ]
[ fanpages ]

You're very welcome.

Thanks for closing the question so promptly.

BFN,

fp.