Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2
Default Macro commands to assign colors to each line in an Excel chart.

Is there a macro command that will assign a user specifide color to each
individual line of a scatter graph?
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 3,346
Default Macro commands to assign colors to each line in an Excel chart.

Hi,

First, scatter charts do not usually display as lines, so when you say line
what do you mean? You chosen as style with connecting lines? or you are
refering to drop lines, or error bar lines, or...?

You can tell Excel to vary the color by point but if you want to assign
specific colors to specific points you will need to write a macro. What
version of Excel are you using?


--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"JohnnyC" wrote:

Is there a macro command that will assign a user specifide color to each
individual line of a scatter graph?

  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 3,346
Default Macro commands to assign colors to each line in an Excel chart.

Hi,

Here is a macro approach: suppose your data is in the range A2:B12, then
format each of the cell in C2:C12 to the desired color you want to apply to
the line. Then select the chart and run the following macro:

Sub ColorLines()
Dim cell As Range
Dim I As Integer
I = 1
For Each cell In Sheets("Sheet3").Range("C2:C12")
ActiveChart.SeriesCollection(1).Points(I).Select
Selection.Border.ColorIndex = cell.Interior.ColorIndex
I = I + 1
Next cell
End Sub

Remember the first color is ignored because there is no line associated with
the first data point.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"JohnnyC" wrote:

Is there a macro command that will assign a user specifide color to each
individual line of a scatter graph?

  #4   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2
Default Macro commands to assign colors to each line in an Excel chart

I have just started using Excel 2007 and have a macro that is not working
from the 2003 version. Here is the old code for adjusting the line color for
the third line in the XYScatterLines graph :

ActiveChart.Legend.LegendEntries(3).LegendKey.Sele ct
With Selection.Border
.ColorIndex = 3
.Weight = xlThin
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = 3
.MarkerForegroundColorIndex = 3
.MarkerStyle = xlTriangle
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With

The old version would make the triangles and line connecting the triangles
red, but the new version makes the triangles red, the line connecting the
triangles is not. Any help would be greatly appreciated.

JohnnyC
"Shane Devenshire" wrote:

Hi,

Here is a macro approach: suppose your data is in the range A2:B12, then
format each of the cell in C2:C12 to the desired color you want to apply to
the line. Then select the chart and run the following macro:

Sub ColorLines()
Dim cell As Range
Dim I As Integer
I = 1
For Each cell In Sheets("Sheet3").Range("C2:C12")
ActiveChart.SeriesCollection(1).Points(I).Select
Selection.Border.ColorIndex = cell.Interior.ColorIndex
I = I + 1
Next cell
End Sub

Remember the first color is ignored because there is no line associated with
the first data point.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"JohnnyC" wrote:

Is there a macro command that will assign a user specifide color to each
individual line of a scatter graph?

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
assign the same macro to every line in worksheet Hannah Excel Worksheet Functions 1 May 22nd 07 10:11 AM
Chart line colors Pieter[_2_] Charts and Charting in Excel 1 March 9th 07 05:53 PM
assign permanent colors to bars/values in a pivot chart Rose73 Charts and Charting in Excel 1 June 1st 06 05:59 PM
Line chart colors T Charts and Charting in Excel 0 April 15th 06 12:55 PM
Assign commands to function keys Gerry Excel Discussion (Misc queries) 4 August 8th 05 05:14 PM


All times are GMT +1. The time now is 07:32 PM.

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"