Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 25
Default Conditional formatting of lines in a chart

Is there any way that one can change the color of a line in the chart
depending on the value of some other cell in the spreadsheet e.g., if a
certain condition is true, the line (or point on the line) is blue and if it
is false the line (or point on the line) is red.
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default Conditional formatting of lines in a chart

Points on a line are probably easier:

http://peltiertech.com/Excel/Charts/...nalChart1.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"jonny" wrote in message
...
Is there any way that one can change the color of a line in the chart
depending on the value of some other cell in the spreadsheet e.g., if a
certain condition is true, the line (or point on the line) is blue and if
it
is false the line (or point on the line) is red.



  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 235
Default Conditional formatting of lines in a chart

Jon's method is preferred, but if you feel like using VBA something like
below might be tailored to work for you. Assuming an embedded chart, copy
the procedure into a sheet module containing that chart. In this example the
procedure will change the color of the first series based on a TRUE or FALSE
value entered into cell A1.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Not Intersect(Target, Range("A1")) Is Nothing Then

Dim Cht As ChartObject
Dim Srs As Series

'The name of the chart (i.e. Cht1)
Set Cht = ActiveSheet.ChartObjects("Cht1")

'The number of the series that you want to change i.e. 1
Set Srs = Cht.Chart.SeriesCollection(1)

If IsEmpty("A1") = True Then
Exit Sub
ElseIf Range("A1").Value = True Then
Cht.Activate
'The color number of the series if value = TRUE
Srs.Border.ColorIndex = 5
Srs.MarkerBackgroundColorIndex = 5
Srs.MarkerForegroundColorIndex = 5
ElseIf Range("A1").Value = False Then
Cht.Activate
'The color number of the series if value = FALSE
Srs.Border.ColorIndex = 7
Srs.MarkerBackgroundColorIndex = 7
Srs.MarkerForegroundColorIndex = 7
End If

Range("A2").Select

End If

End Sub

--
John Mansfield
http://cellmatrix.net





"jonny" wrote:

Is there any way that one can change the color of a line in the chart
depending on the value of some other cell in the spreadsheet e.g., if a
certain condition is true, the line (or point on the line) is blue and if it
is false the line (or point on the line) is red.

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
conditional formatting for multiple lines using similar criteria? I Am Baltimore Excel Worksheet Functions 2 August 3rd 06 09:26 PM
formatting of multiple lines on a chart robert111 Charts and Charting in Excel 1 May 31st 06 09:41 AM
Conditional Formatting - Drawing Lines Between Sorted Groups Sam via OfficeKB.com Excel Discussion (Misc queries) 2 May 26th 06 03:02 PM
Conditional formatting in a chart Baro Charts and Charting in Excel 3 June 27th 05 06:01 AM
Formatting lines between data points in a line chart ltanner Charts and Charting in Excel 2 March 13th 05 05:12 AM


All times are GMT +1. The time now is 11:54 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"