Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
hmm hmm is offline
external usenet poster
 
Posts: 175
Default Conditionally format points based on a third column

I would like the color of my data points to vary based not on their x or y
value, but rather on a third column running alongside them. How can I do it?
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 235
Default Conditionally format points based on a third column

Assuming your third column is column "C" and that you would want to change
the colors of the XY points based on the names Jim, Frank, or Kim, a VBA
option could look like this (does not include any error handling):

Sub ChangeXYColors()
Application.ScreenUpdating = False
Dim Rng As Range
Cnt = 1
For Each Rng In Range("C2:C10")
ActiveSheet.ChartObjects("Chart1").Activate
ActiveChart.SeriesCollection(1).Points(Cnt).Select
If Rng.Value = "Jim" Then
With Selection
.MarkerBackgroundColorIndex = 10
.MarkerForegroundColorIndex = 10
End With
ElseIf Rng.Value = "Frank" Then
With Selection
.MarkerBackgroundColorIndex = 11
.MarkerForegroundColorIndex = 11
End With
ElseIf Rng.Value = "Kim" Then
With Selection
.MarkerBackgroundColorIndex = 12
.MarkerForegroundColorIndex = 12
End With
End If
Cnt = Cnt + 1
Next Rng
ActiveChart.Deselect
End Sub

--
John Mansfield
http://cellmatrix.net





"hmm" wrote:

I would like the color of my data points to vary based not on their x or y
value, but rather on a third column running alongside them. How can I do it?

  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 235
Default Conditionally format points based on a third column

In addition to the VBA example, I've added a worksheet example to my site -
the entry is dated today.

--
John Mansfield
http://cellmatrix.net





"John Mansfield" wrote:

Assuming your third column is column "C" and that you would want to change
the colors of the XY points based on the names Jim, Frank, or Kim, a VBA
option could look like this (does not include any error handling):

Sub ChangeXYColors()
Application.ScreenUpdating = False
Dim Rng As Range
Cnt = 1
For Each Rng In Range("C2:C10")
ActiveSheet.ChartObjects("Chart1").Activate
ActiveChart.SeriesCollection(1).Points(Cnt).Select
If Rng.Value = "Jim" Then
With Selection
.MarkerBackgroundColorIndex = 10
.MarkerForegroundColorIndex = 10
End With
ElseIf Rng.Value = "Frank" Then
With Selection
.MarkerBackgroundColorIndex = 11
.MarkerForegroundColorIndex = 11
End With
ElseIf Rng.Value = "Kim" Then
With Selection
.MarkerBackgroundColorIndex = 12
.MarkerForegroundColorIndex = 12
End With
End If
Cnt = Cnt + 1
Next Rng
ActiveChart.Deselect
End Sub

--
John Mansfield
http://cellmatrix.net





"hmm" wrote:

I would like the color of my data points to vary based not on their x or y
value, but rather on a third column running alongside them. How can I do it?

  #4   Report Post  
Posted to microsoft.public.excel.charting
hmm hmm is offline
external usenet poster
 
Posts: 175
Default Conditionally format points based on a third column

Thanks John.

"John Mansfield" wrote:

In addition to the VBA example, I've added a worksheet example to my site -
the entry is dated today.

--
John Mansfield
http://cellmatrix.net





"John Mansfield" wrote:

Assuming your third column is column "C" and that you would want to change
the colors of the XY points based on the names Jim, Frank, or Kim, a VBA
option could look like this (does not include any error handling):

Sub ChangeXYColors()
Application.ScreenUpdating = False
Dim Rng As Range
Cnt = 1
For Each Rng In Range("C2:C10")
ActiveSheet.ChartObjects("Chart1").Activate
ActiveChart.SeriesCollection(1).Points(Cnt).Select
If Rng.Value = "Jim" Then
With Selection
.MarkerBackgroundColorIndex = 10
.MarkerForegroundColorIndex = 10
End With
ElseIf Rng.Value = "Frank" Then
With Selection
.MarkerBackgroundColorIndex = 11
.MarkerForegroundColorIndex = 11
End With
ElseIf Rng.Value = "Kim" Then
With Selection
.MarkerBackgroundColorIndex = 12
.MarkerForegroundColorIndex = 12
End With
End If
Cnt = Cnt + 1
Next Rng
ActiveChart.Deselect
End Sub

--
John Mansfield
http://cellmatrix.net





"hmm" wrote:

I would like the color of my data points to vary based not on their x or y
value, but rather on a third column running alongside them. How can I do it?

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
How do I conditionally delete rows based on cell contents? John Chan Excel Worksheet Functions 3 May 17th 23 03:45 AM
Conditional Format a column based on another Karm Excel Discussion (Misc queries) 6 October 30th 06 11:39 AM
Conditionally summing cells based on conditions in other rows Bert Excel Worksheet Functions 3 June 20th 06 11:06 AM
date updated conditionally based upon other cells RachRB Excel Worksheet Functions 1 January 16th 06 02:25 PM
New column based on row cell format peteracain Excel Discussion (Misc queries) 1 August 8th 05 01:37 PM


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