Solved

How to Format Excel Chart line color in VBA

Posted on 2011-03-16
3
541 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

763 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