Graph?--Need line to be different colors based on value...


Posted by Bill James on September 01, 1999 3:29 PM

I would like to have my line change color based upon
a conditional formula. The graphing function doesn't
seem to have a 'conditional color' dialog function.
Any ideas? Thanks in advance

Posted by Chris on September 02, 1999 5:30 AM

Bill,

You can modify the color of individual points on a chart using VBA. What you would do is loop through the source data and update the chart based on your criteria. You would most likely use a Select Case statement pick the colors based on the data values. The following code shows how to change the color of one data point in the series.

Sheets("Sheet1").ChartObjects("Chart 1").Chart.SeriesCollection(1).Points(1).Interior.ColorIndex = 14

If you aren't familiar with VBA, I highly encourage learning it. In the mean time, if you write your needs, someone will probably help you out.

Chris



Posted by Ivan Moala on September 02, 1999 4:06 PM


Bill, everything Chris has said is right.
I'm not sure but you may also have wanted to
have the colours change dynamically as your
sheet formulas / criteria change/update. In this
case in the worksheet that you have your graph
and assuming you have your macro to do the color
changing you will need to monotor the cells that
have your criteria eg if(A1<20,something,somethingelse)
in B1. You would need to use something in;
Private Sub Worksheet_Change(ByVal Target As Excel.Range)


Ivan