Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 124
Default How to format a line between two points on a line chart?

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.SeriesCollection( 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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default How to format a line between two points on a line chart?

Hi Mark,

I think that the question marks are only to indicate that you need to edit
that part of the code with your sheet name and chart name and then close the
double quotes. Anyway try the following but you will probably still need to
edit the sheet name and chart name and maybe even the SeriesCollection Index:-

With Worksheets("Sheet1").ChartObjects("Chart 1").Chart.SeriesCollection(1)
With .Points(4).Border 'Formats from point 3 to point 4
.ColorIndex = 3 'Red
.Weight = xlThin
'.Weight = xlThick 'code included for info
.LineStyle = xlContinuous
End With
End With

Weight and linestyle can be omitted if you don't want to change them.


Alternative method of codeing:-

With Worksheets("Sheet1").ChartObjects("Chart 1").Chart.SeriesCollection(1)
.Points(4).Border.ColorIndex = 3 'Formats from point 3 to point 4
.Points(5).Border.ColorIndex = 6 'Formats from point 4 to point 5
End With

--
Regards,

OssieMac

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default How to format a line between two points on a line chart?

Hi again Mark,

If you want to put that into a loop for several points then something like
this:-

Dim p As Long

For p = 4 To 7
With Worksheets("Sheet1").ChartObjects("Chart
1").Chart.SeriesCollection(1)
With .Points(p).Border 'Formats from point 3 to point 4
.ColorIndex = 3
.Weight = xlThin
'.Weight = xlThick 'Included for info
.LineStyle = xlContinuous
End With
End With
Next p

--
Regards,

OssieMac


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Points on Line Chart Douglas Carr Charts and Charting in Excel 1 January 29th 10 08:34 PM
Conditionally Format Data Points in Line Chart Steve Krieger Charts and Charting in Excel 0 May 4th 09 07:47 PM
How to format a line between two points? Mark Stephens Charts and Charting in Excel 6 April 20th 09 01:25 AM
Line chart with two series; how to add points to one and not the other? chowgirl Charts and Charting in Excel 0 February 8th 06 10:10 PM
Null points in a line chart rmellison Excel Discussion (Misc queries) 1 September 7th 05 01:21 AM


All times are GMT +1. The time now is 09:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"