Solved

How to Format Excel Chart line color in VBA

Posted on 2011-03-16
3
549 Views
Last Modified: 2012-05-11
I have an excel chart I'm trying to reformat. The series collection alternates between stacked and line charts and I want to color the lines the so that each line is the same color as the prior stacked series.
To that extent I tried:
        Dim lColor As Long
        For ctr = 2 To 10 Step 2
            lColor = Sheets(sSheet).ChartObjects("Chart 1").Chart.SeriesCollection(ctr - 1).Border.ColorIndex
            Sheets(sSheet).ChartObjects("Chart 1").Chart.SeriesCollection(ctr).Border.ColorIndex = lColor
        Next ctr

Open in new window


but it doesn't seem to work. Does anyone have any ideas?
0
Comment
Question by:stopher2475
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
telyni19 earned 500 total points
ID: 35152332
Try Color instead of ColorIndex, and Interior instead of Border for the stacked series.
Sub ChartColorTest()
    Dim lColor As Long
    For ctr = 2 To 10 Step 2
        lColor = Sheets(sSheet).ChartObjects("Chart 1").Chart.SeriesCollection(ctr - 1).Interior.Color
        Sheets(sSheet).ChartObjects("Chart 1").Chart.SeriesCollection(ctr).Border.Color = lColor
    Next ctr
End Sub

Open in new window

0
 
LVL 2

Author Comment

by:stopher2475
ID: 35177814
Will give it a shot in the AM.
0
 
LVL 2

Author Closing Comment

by:stopher2475
ID: 35181022
That seems to have done the trick.
Thanks for the help!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question