Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 671
  • Last Modified:

Excel VBA approach to color a segment in a line chart

I know how to color the whole line, and I have a routine that enumerates the points.  What is the property I can update to change a single segment at a certain point in a line chart?

Dave
0
dlmille
Asked:
dlmille
  • 3
2 Solutions
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Hello,

which version of Excel?

In 2010 you can use something along these lines (formats the 3rd data point of the first series, change to suit)

    With ActiveChart.SeriesCollection(1).Points(3).Format.Line
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorAccent3
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
    End With

Open in new window


cheers, teylyn
0
 
dlmilleAuthor Commented:
Version 2007.

Thanks for pointing me to what I should have found in the object.

I'm not sure themecolor is correct as when I test this its zero for a chart where I've manually colored the segments.

SchemeColor, however has values.  I'm trying to relate a set of cells that are colored with the chart line segments.  What's the relationship with
a range.interior.color or .colorindex with schemecolor (or other related color property I should be using)?

Thanks,

Dave
0
 
dlmilleAuthor Commented:
Got it - I just remembered + 7 on schemecolor will match a range.interior.colorindex color.

Thanks!

Dave
0
 
dlmilleAuthor Commented:
Accurate enough for me to get to the correct property I needed...
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now