Changing line segment color in chart

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
21,894
Office Version
  1. 365
  2. 2019
  3. 2013
  4. 2007
Platform
  1. Windows
Hi All
I'm now completely intrigued.
A co-worker has created a line chart based on measurements for the year by month.
What has me fascinated is that if a segment of the series is positive ( or going up) it changes color. If it is going down it's different color again.
Can anyone out there enlighten me as to the code required to do this.
It's simply curiosity, I really can't see a genuine use for it in my business !!

Thank you for any inputs / comments.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Ok, I've got myself to here, but the line in red, I believe is incorrect.
I've tried a few different variations, but no luck.
This code will activate the first segment of line but does nothing AND doesn't move to the next one either.
Rich (BB code):
Sub ChangeColors()
    Dim i As Long
    Dim points(12) As Object
    ActiveSheet.ChartObjects("Chart 1").Activate
        For i = LBound(points) To UBound(points)
         With ActiveSheet.ChartObjects("Chart 1").Chart.SeriesCollection(1).points
            On Error Resume Next
            If points(i).Border.Value < 6 Then
                points(i).Border.ColorIndex = 4
            Else
                points(i).Border.ColorIndex = 8
            End If
        End With
        Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top