Hi, all. I am wondering if there is a way to make the data points in graphs change color according to their value. I’m trying to create a ‘dashboard’ that shows red when the data is below an assigned value, black if equal, or green if above the value. Is there any way to get a graph to do this?
Thanks for any and all help! Judy
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Different colored data points in a graph? (Excel ’97 or 2000)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Different colored data points in a graph? (Excel ’97 or 2000)
- This topic has 16 replies, 6 voices, and was last updated 23 years, 3 months ago.
AuthorTopicWSdevore1
AskWoody LoungerJanuary 14, 2002 at 2:21 am #365335Viewing 4 reply threadsAuthorReplies-
WSWebGenii
AskWoody Lounger -
WSGraemeH
AskWoody LoungerJanuary 14, 2002 at 12:12 pm #563625I use this to change the colour of out-of-limits points on control charts in excel:
Private Sub MarkPoint(ByVal i As Long, j As Long)
””change the marker style of points outside control limits
Dim srs As Series
Dim pnt As PointOn Error Resume Next
Set srs = myChart.SeriesCollection(1)
With srs
Set pnt = .Points(i)
pnt.MarkerBackgroundColorIndex = j
pnt.MarkerForegroundColorIndex = j
pnt.MarkerSize = 7
pnt.MarkerStyle = xlMarkerStyleCircle
End With
On Error GoTo 0End Sub
A bit of hacking about should get it to work for you – hope it helps
Graeme
-
WSdevore1
AskWoody Lounger
-
-
WSSammyB
AskWoody LoungerJanuary 14, 2002 at 12:23 pm #563630That was a fun problem, but I don’t like the solution very much. As the macro below shows, I moved the chart values to an array v. I could access them directly via “for each y in .Values”, but could not access them via .Values(i) nor .Values.Item(i). What’s up with this? Anyway, I shouldn’t knock sucess. I’ve attached the workbook, but here’s the macro:
Option Explicit Sub ColorColumns() Const BAD = 12000, OK = 15000 Const RED = 3, BLACK = 1, GREEN = 50 Dim i As Integer Dim v() As Variant If TypeName(ActiveSheet) "Chart" Then Exit Sub With ActiveChart.SeriesCollection(1) v = .Values For i = 1 To .Points.Count Select Case v(i) Case Is > OK .Points(i).Interior.ColorIndex = GREEN Case Is > BAD .Points(i).Interior.ColorIndex = BLACK Case Else .Points(i).Interior.ColorIndex = RED End Select Next i End With End Sub
-
WSfburg
AskWoody LoungerJanuary 14, 2002 at 7:34 pm #563785Sammy,
I downloaded your spreadsheet and tried running it in Excel 97 SR1. Got a compile error “can’t assign to array” for the statement
v = .ValuesSince this was something I was interested in (see my post on this thread for a somewhat related solution), I’d thought I’d give it a whirl. Any ideas on this?
Fred
-
WSSammyB
AskWoody LoungerJanuary 15, 2002 at 12:26 pm #563930 -
WSfburg
AskWoody LoungerJanuary 16, 2002 at 11:18 am #564137Sammy,
On a PC with Excel 2000, I tried taking the
v = .Values
statement from your code and putting it into a loop. But I couldn’t get the thing to work no matter what combination of things I had on the right side. Of course, I was just guessing the syntax [v(j)=…(j)] last night when I had no references. Now I’m looking at Walkenbach’s 2000 Power Pgmg with VBA. It says (pg 490): the Values property returns a variant array. So what you had should have worked.Your different colors for the bars (as opposed to the scatter chart) helped me at least to the extent that this was possible to do (or it’s almost there). If you look at the thread I referred to earlier in this thread, you’ll see I originally thought there was a VBA solution to my problem. However between Hans and myself, we came up with several non VBA solutions. My problem was that a teacher wanted a bar chart where each student was on the x-axis but the height of the bar was dependent on the grade. So, for example, below 70 was failing and that was red; 70-79=blue,80-89=orange;99+=green.
Fred
-
WSWebGenii
AskWoody Lounger -
WSfburg
AskWoody LoungerJanuary 21, 2002 at 2:49 am #565032Catherine,
Earlier in this thread, I posted the link to the thread from the summer. It was post number 107801 on 14-Jan-02 11:21. The link, per that email, is coloring the bars .
There were 2 solutions – which were for bar graphs (which this thread seemed to start with). 1 came from Hans Pottel which used a pivot table chart. This is only available in Excel 2000. I came up with the other solution but don’t recall what it was, altho I think it applied to Excel 97 as well. Both were discussed in the above linked thread; I think workbook solutions were attached there.
I think I have a workbook for each of Hans’ and my solutions. But that’s on another computer. If you can’t get what you want from the other thread, let me know and I’ll attach each workbook to separate emails.
Fred
-
WSWebGenii
AskWoody Lounger
-
-
WSrory
AskWoody LoungerJanuary 16, 2002 at 12:38 pm #563933Edited by rory on 16-Jan-02 13:38.
Sam,
As best I can figure (not saying much), the .values property seems to return a collection rather than an array, which is why you can use “For each y in .values “. I can only assume that no item method was implemented for the collection otherwise you ought to be able to use an index to retrieve an individual value.**Edited by me as my original post was rubbish! -Rory**
-
-
-
WSdevore1
AskWoody LoungerJanuary 15, 2002 at 1:38 am #563880 -
WSSammyB
AskWoody LoungerJanuary 15, 2002 at 12:21 pm #563928Judy, sorry, I just assumed that you had a bar chart. For a scatter chart, you want to mess with MarkerBackgroundColorIndex:
Sub ColorPoints() Const BAD = 12000, OK = 15000 Const RED = 3, BLACK = 1, GREEN = 50 Dim i As Integer Dim v() As Variant If TypeName(ActiveSheet) "Chart" Then Exit Sub With ActiveChart.SeriesCollection(1) v = .Values For i = 1 To .Points.Count Select Case v(i) Case Is > OK .Points(i).MarkerBackgroundColorIndex = GREEN .Points(i).MarkerForegroundColorIndex = GREEN .Points(i).MarkerSize = 10 Case Is > BAD .Points(i).MarkerBackgroundColorIndex = BLACK .Points(i).MarkerForegroundColorIndex = BLACK .Points(i).MarkerSize = 10 Case Else .Points(i).MarkerBackgroundColorIndex = RED .Points(i).MarkerForegroundColorIndex = RED .Points(i).MarkerSize = 10 End Select Next i End With End Sub
Notice that I also made the points bigger, so that they could be seen. What type of chart are you using? Are there lines that need to be colored, also?
-
WSdevore1
AskWoody LoungerJanuary 16, 2002 at 11:53 am #564142You are incredible! I’m really trying to make a dashboard for the executives, the kind that has 10-12 specific
numeric targets and the associated ongoing (quarterly) data that tells them without looking whether we are
exceeding or way behind target. So most of them will be simple line graphs with the data points changing
color. I think we’d be better off not trying to change the lines since there is always one more data point than
line, and they would invariably argue whether it should be the line before, or after, the data point.How/ where did you learn this? I’m just a simple Excel user struggling now with the conversion issues of ’97 to
2000. I have heard that Excel can create reports basically equal to what Access can do, and can hold macros
and formulas which do all that I want. But I’m not a programmer, and have struggled to learn the simple SQL
formulas needed to make Access useful.
Judy
-
-
-
-
WSfburg
AskWoody LoungerJanuary 14, 2002 at 3:21 pm #563687Judy,
I had a somewhat related problem last summer in a thread about Coloring the Bars. In this problem, I wanted to be able to make the bars of a bar chart a particular color depending on the grade (student test scores in range1 had color1, in range2 had color2, etc.). I know your post talked about wanting to color the data points, but maybe the approach in the above can help.
Fred
-
WSSammyB
AskWoody LoungerJanuary 28, 2002 at 1:20 pm #566376Well, better late than never. There is a way to format the points/bars based on the values, don’t even need VBA. Check out John Peltier solution at http://www.geocities.com/jonpeltier/Excel/…onalChart1.html. The rest of his site also has some great tips. –Sam
Viewing 4 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Mozilla Firefox Security Updates! Released late 17th May 2025
by
Alex5723
1 hour, 41 minutes ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
5 hours, 31 minutes ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
5 hours, 40 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
4 hours, 27 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
15 hours, 29 minutes ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
5 hours, 54 minutes ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
18 hours, 10 minutes ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
10 hours, 25 minutes ago -
Some advice for managing my wireless internet gateway
by
LHiggins
6 hours, 6 minutes ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
12 hours, 22 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
1 day, 3 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
23 hours, 56 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
13 hours, 59 minutes ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
1 day, 17 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 hour, 33 minutes ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
5 hours, 14 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
1 day, 20 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
1 day, 20 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
1 day, 8 hours ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
2 days, 4 hours ago -
0Patch, where to begin
by
cassel23
1 day, 22 hours ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
2 days, 18 hours ago -
89 million Steam account details just got leaked,
by
Alex5723
2 days, 5 hours ago -
KB5058405: Linux – Windows dual boot SBAT bug, resolved with May 2025 update
by
Alex5723
3 days, 2 hours ago -
A Validation (were one needed) of Prudent Patching
by
Nibbled To Death By Ducks
2 days, 17 hours ago -
Master Patch Listing for May 13, 2025
by
Susan Bradley
2 days, 4 hours ago -
Installer program can’t read my registry
by
Peobody
1 hour, 46 minutes ago -
How to keep Outlook (new) in off position for Windows 11
by
EspressoWillie
2 days, 15 hours ago -
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
2 days, 22 hours ago -
False error message from eMClient
by
WSSebastian42
3 days, 13 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.