Solved

How to set the color of the lines in a (line) excel chart, programmed via visual basic

Posted on 2003-11-12
3
365 Views
Last Modified: 2013-12-26
Hello,

I've already got the following code, I would like to know how I can set the colours of the 3 different seriescollections (ranges) in the chart.
Thnx in advantage.

  Dim objXLRange As Excel.Range
  Dim objXlChart As Excel.Chart
 
  Set objXLRange = excWS.Range("B35", "E37")
  Set objXlChart = excWS.ChartObjects.Add(50, 40, 300, 200).Chart
 
  With objXlChart
    .ChartType = xlLine
    .SetSourceData objXLRange, xlRows
    .HasTitle = True
    With .ChartTitle
      .Characters.Text = "prestaties t.o.v. gemiddelde"
      .Font.Size = 16
      .Font.Name = "Verdana"
    End With
    With .SeriesCollection(1)
      .ApplyDataLabels Type:=xlDataLabelsShowValue
    End With
    With .SeriesCollection(2)
      .ApplyDataLabels Type:=xlDataLabelsShowValue
    End With
    With .SeriesCollection(3)
      .ApplyDataLabels Type:=xlDataLabelsShowValue
    End With
  End With

Greetz,
Peter
0
Comment
Question by:peterhav
3 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 9731927

    Rows("3:3").Select
    With Selection.Interior
        .ColorIndex = 3
        .Pattern = xlSolid
    End With
0
 

Author Comment

by:peterhav
ID: 9732116
I would like to change the colour of the lines in the graph, not of the original rows in the excel sheet.
0
 
LVL 9

Accepted Solution

by:
p_sie earned 100 total points
ID: 9733339
.SeriesCollection(2).Border.ColorIndex = 50            makes the line green!

You can get this code by recording a macro in Excel and then see the code in VBA, like you
can find out may other methodes to do things programmatically in Excel!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now