change rgb value for fills color of a serie in a chart with vba

I

Ingrid Makkinje

I am trying to change the fills color of a serie in an MS
Graph chart by using the code as listed below. I really
want to use an RGB value and not one of the colors from
the MS Graph palette. I hope someone can help me.
****************************************************


Sub changeseriecolor()

Set myChart = ActiveWindow.Selection.ShapeRange
(1).OLEFormat.Object


myChart.SeriesCollection(2).Interior.Color = RGB(Red:=2,
Green:=110, Blue:=6)
End Sub

I have also tried this:

Sub changeseriecolor()

Set myChart = ActiveWindow.Selection.ShapeRange
(1).OLEFormat.Object


myChart.SeriesCollection(2).Interior.Color = RGB(2, 110,
6)
End Sub
 
A

Andy Pope

Hi Ingrid,

You need to reference the application and chart objects.

Sub changeseriecolor()
Set myChart = ActiveWindow.Selection.ShapeRange(1) _
..OLEFormat.Object.Application.chart
myChart.SeriesCollection(2).Interior.Color _
= RGB(Red:=2, Green:=110, Blue:=6)
End Sub

Cheers
Andy
 
I

Ingrid Makkinje

Hi Andy,
Thank you for your reply. I have changed the code but it
still does not work. The fill color still changes to the
color which is the same as the index color 10.
Any idea what I do wrong?
Ingrid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top