Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to Format Excel Chart line color in VBA

Posted on 2011-03-16
3
Medium Priority
?
557 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

721 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