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

x
?
Solved

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

Posted on 2003-11-12
3
Medium Priority
?
373 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

926 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