Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Charting / October 2007

Tip: Looking for answers? Try searching our database.

Conditionally format points based on a third column

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hmm - 11 Oct 2007 15:46 GMT
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?
John Mansfield - 11 Oct 2007 18:32 GMT
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

Signature

John Mansfield
http://cellmatrix.net

> 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?
John Mansfield - 12 Oct 2007 17:37 GMT
In addition to the VBA example, I've added a worksheet example to my site -
the entry is dated today.

Signature

John Mansfield
http://cellmatrix.net

> 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
[quoted text clipped - 30 lines]
> > 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?
hmm - 14 Oct 2007 09:35 GMT
Thanks John.

> In addition to the VBA example, I've added a worksheet example to my site -
> the entry is dated today.
[quoted text clipped - 33 lines]
> > > 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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.