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, 4 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
-
iOS 26,, MacOS 26 : Create your own AI chatbot
by
Alex5723
1 hour, 16 minutes ago -
New PC transfer program recommendations?
by
DaveBoston
16 minutes ago -
Windows 11 Insider Preview Build 22631.5545 (23H2) released to Release Preview
by
joep517
5 hours, 20 minutes ago -
Windows 10 Build 19045.6029 (22H2) to Release Preview Channel
by
joep517
5 hours, 22 minutes ago -
Best tools for upgrading a Windows 10 to an 11
by
Susan Bradley
39 minutes ago -
The end of Windows 10 is approaching, consider Linux and LibreOffice
by
Alex5723
1 hour, 21 minutes ago -
Extended Windows Built-in Disk Cleanup Utility
by
bbearren
3 hours, 31 minutes ago -
Win 11 24H2 June 2025 Update breaks WIFI
by
dportenlanger
1 day ago -
Update from WinPro 10 v. 1511 on T460p?
by
CatoRenasci
13 hours, 53 minutes ago -
System Restore and Updates Paused
by
veteran
1 day, 2 hours ago -
Windows 10/11 clock app
by
Kathy Stevens
13 hours, 57 minutes ago -
Turn off right-click draw
by
Charles Billow
1 day, 6 hours ago -
Introducing ChromeOS M137 to The Stable Channel
by
Alex5723
1 day, 9 hours ago -
Brian Wilson (The Beach Boys) R.I.P
by
Alex5723
3 hours, 29 minutes ago -
Master patch listing for June 10, 2025
by
Susan Bradley
1 day, 11 hours ago -
Suggestions for New All in One Printer and a Photo Printer Windows 10
by
Win7and10
14 hours, 6 minutes ago -
Purchasing New Printer. Uninstall old Printer Software First?
by
Win7and10
1 day, 17 hours ago -
KB5060842 Issue (Minor)
by
AC641
5 hours, 20 minutes ago -
EchoLeak : Zero Click M365 Copilot leak sensitive information
by
Alex5723
2 days ago -
24H2 may not be offered June updates
by
Susan Bradley
16 hours, 56 minutes ago -
Acronis : Tracking Chaos RAT’s evolution (Windows, Linux)
by
Alex5723
2 days, 12 hours ago -
June 2025 updates are out
by
Susan Bradley
9 minutes ago -
Mozilla shutting Deep Fake Detector
by
Alex5723
3 days, 3 hours ago -
Windows-Maintenance-Tool (.bat)
by
Alex5723
2 days, 13 hours ago -
Windows 11 Insider Preview build 26200.5641 released to DEV
by
joep517
3 days, 6 hours ago -
Windows 11 Insider Preview build 26120.4250 (24H2) released to BETA
by
joep517
3 days, 6 hours ago -
Install Office 365 Outlook classic on new Win11 machine
by
WSrcull999
3 days, 6 hours ago -
win 10 to win 11 with cpu/mb replacement
by
aquatarkus
2 days, 22 hours ago -
re-install Windows Security
by
CWBillow
3 days, 9 hours ago -
WWDC 2025 Recap: All of Apple’s NEW Features in 10 Minutes!
by
Alex5723
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.