View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.charting
Andy Pope Andy Pope is offline
external usenet poster
 
Posts: 2,489
Default How to format a line between two points?

Hi,

This sort of thing?

Dim objSeries As Series

Set objSeries = ActiveSheet.ChartObjects(1).Chart.SeriesCollection (1)
objSeries.Format.Line.ForeColor.ObjectThemeColor = msoThemeColorAccent3

Cheers
Andy

mark Stephens wrote:
Thanks Andy, works like a dream... do you know how to formata line using
ther excel 2007 built in presets via vba as the macro won't capture them?

Thanks and regards, mark

"Andy Pope" wrote in message
...

Hi,

Try this, change the loop values to suit.

With ActiveSheet.ChartObjects(1).Chart.SeriesCollection (1)
.Format.Line.Visible = msoCTrue
.Format.Line.ForeColor.RGB = vbBlue
For bPointNo = 5 To 10
With .Points(bPointNo).Format.Line
.ForeColor.RGB = vbRed
End With
Next
End With

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Mark Stephens" wrote in message
...

Hi,

Used to be as easy as recording a macro and seeing how to do it, god
knows why microsoft chose to drop this useful feature... c'est la vie.

I have a line chart and wish to apply a different colour to a portion of
the line according to some vba parameters i have defined.

It would be ideal to be able to do ti without activation the chart, I
found some code posted by John Peltier in December:

With Worksheets("sheet
2?).ChartObjects("chart1?).Chart.SeriesCollecti on(1)

but this doesn't seem to work giving the error:

Compile error:

Expected: list seperator or )


and highlighting the quote mark after sheet 2 to the bracket after chart1

I have tried messing about with it but can't get it to work.

Anyway, that one aside, I want to say:

For bPointNo = 2303 To 2666

ActiveSheet.ChartObjects("Cht_Comparison").Activat e
ActiveChart.SeriesCollection(1).Points(2303).Selec t
ActiveChart.SeriesCollection(1).Colour = Red

Next bPointNo

The last line is obviously not going to work so I have put it just to
show what I am trying to achieve.

This should be so straightforward, I am pretty disappointed in Microsoft,
why I wonder have they chosen to make excel so un user friendly to vba
users?

Thanks and regards, Mark








--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info