Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 3rd, 2009, 03:20 PM
Registered User
 
Join Date: Feb 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing Marker color in Excel 2002 vba

I'm stuck trying to change the marker colors on some line charts I've got. This code was written a while ago, and I'm trying to make reasonable use of what's there. I'm running into problems trying to use the .MarkerForegroundColor method. The routine below is called for every line I want to add to my line chart. The data points are passed in YValues. The chart is an OWC chartspace control. I get error 13 on the line "Set oSeries = chrtContainer.Charts(0).SeriesCollection.Add" when I try the code below. Can someone help me out? Thanks
Code:
Public Sub AddChartData(ByRef chrtContainer As ChartSpace, Caption As String, RowLabels As Variant, YValues As Variant)    
' Declare the necessary local variables    
Dim oSeries As Series    
Dim pt As Point    
' Add a series to collection    
Set oSeries = chrtContainer.Charts(0).SeriesCollection.Add    
' Set series properties    
With oSeries
        .Caption = Caption
        .SetData chDimCategories, chDataLiteral, RowLabels
        .SetData chDimValues, chDataLiteral, YValues
        .Type = chChartTypeLineMarkers
        For Each pt In .Points
            pt.MarkerBackgroundColor = RGB(0, 255, 0)  ' green           
            pt.MarkerForegroundColor = RGB(255, 0, 0)  ' red
        Next pt
    End With
End Sub
I call this routine with the following:Call AddChartData(Me.chrtResults, Caption, RowLabel, YValues)where Caption is a string, RowLabel and YValues are arrays.Thanks for any help you can provide...

Last edited by boulder_dude2000; February 3rd, 2009 at 03:48 PM.. Reason: highlight owc chartspace





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2002 VBA Programmer's Reference hawlk VB How-To 0 February 4th, 2007 04:35 PM
To edit Series Color in Stacked Line Marker chart Jell General .NET 0 July 12th, 2005 05:20 AM
Suspected Error in "Excel 2002 VBA" book rstober Excel VBA 7 September 2nd, 2004 05:48 PM
A simple question about date in VBA for Excel 2002 Trancefuzion Excel VBA 2 July 29th, 2004 04:37 AM
Excel 2002 VBA Programmers Guide quinoman Wrox Book Feedback 1 June 9th, 2003 09:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.