0

I'm trying to write some scrit to change the color of some points in my chart based on their value but everytime i try to run it, i'm hit with an error here is the code. (i think the error appears when i use .Points(i).Value to retrieve it's value, because i have no problem doing what i want to do using series values).

Thank's for your time.

Sub AutoCouleur()

Dim i As Long
Dim s As Variant

   grph = ActiveWorkbook.Sheets("Tableau récapitulatif").ChartObjects("Graphique 1")
 
 For Each s In grph.SeriesCollection
 For i = 1 To s.Points.Count
 If s.Points(i).Value > 1.1 And s.Points(i).Value < 2 Then s.Points(i).MarkerBackgroundColor = RGB(0, 153, 0)
 If s.Points(i).Value > 0.3 And s.Points(i).Value < 1 Then s.Points(i).MarkerBackgroundColor = RGB(80, 209, 9)
 If s.Points(i).Value < 0.2 And s.Points(i).Value > -0.2 Then s.Points(i).MarkerBackgroundColor = RGB(90, 12, 9)
 If s.Points(i).Value < -0.3 And s.Points(i).Value > -1 Then s.Points(i).MarkerBackgroundColor = RGB(90, 209, 9)
 If s.Points(i).Value < -1 Then s.Points(i).MarkerBackgroundColor = RGB(255, 100, 9)

 
 
 Next i
 Next s
 
 


        
End Sub
  • A Point object doesn't have a value property, but a [Series](https://learn.microsoft.com/en-us/office/vba/api/excel.series.value) does. Try `s.Values(i)` – chris neilsen Nov 26 '20 at 09:44
  • https://stackoverflow.com/questions/15122329/determining-the-value-of-a-point-in-excel-vba – Siddharth Rout Nov 26 '20 at 09:46

0 Answers0