I need to bold a bar in the attached graph. The graph is not “attached” to the rows in excel (for various reasons it can’t be done like this). I’ve attached one chart but i have over 100 in my workbook. Anyway, every place that the word “Total” occurs in the text, i need that corresponding bar to be black on the graph. I am doing them manually now which is very time consuming. Can anyone help me write a macro so it can be done automatically. Thanks a lot. I get so much valuable help from this site. Thanks again
![]() |
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 |
-
Bold a bar in a graph (Excel xp)
Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Bold a bar in a graph (Excel xp)
- This topic has 8 replies, 3 voices, and was last updated 22 years, 11 months ago.
Viewing 0 reply threadsAuthorReplies-
WSHansV
AskWoody Lounger -
WSjha900
AskWoody Lounger -
WSHansV
AskWoody LoungerJuly 26, 2002 at 1:05 pm #604202Which bars will be colored black is controlled by the instruction
If InStr(UCase(strVal), “TOTAL”) > 0 Then
This instruction tests whether the string TOTAL occurs somewhere within strVal. strVal is converted to uppercase so that the comparison is not case sensitive. The InStr function returns 0 if the second string is NOT found, and >0 (in fact, the position of of the first character of the second string within the first string) if it is found.
If you want to make the bar black only if the text begins with TOTAL, use
If Left(UCase(strVal), 5) = “TOTAL” Then
If you want to make the bar black only if the text is equal to TOTAL, use
If UCase(strVal) = “TOTAL” Then
If you want the comparison to be case sensitive (i.e. TOTAL is OK, Total and total and tOTaL are not OK), use strVal instead of UCase(strVal) in any of the above instructions.
-
WSjha900
AskWoody Lounger -
WSHansV
AskWoody LoungerJuly 29, 2002 at 6:38 am #604682In your example, the data for the chart are in A3:A19 on the Sheet1 sheet; the names are in A3:A19 on the Chart sheet; so the relative position on the two sheets is the same.
If you are absolutely sure that this is always the case, it’s easy. If not, it’ll become much more complicated.
So let’s assume that the data range and the names range have the same address. Replace
‘ Get text in cell to right of value
strVal = rng.Cells(i, 2)with
‘ Get text in cell corresponding to value
strVal = rng.Cells(i)Explanation: rng is the range on the sheet with the chart with the same “address” as the source range of the series.
In the previous version, this *was* the source range, and the code looked at the cell to the right of the value, because that contained the name.
Now, rng contains the names, so the code looks up rng.Cells(i).Regards,
Hans -
WSjha900
AskWoody LoungerJuly 29, 2002 at 6:02 pm #604822Ok, now i understand about the .rng.
I have 4 charts running across my worksheet. The range encompasses A8:A67 and the series is B3:B62, the next chart’s range is I3:I62 and the series is E3:E62…
Range Series
A8:A67 B3:B62 chart1
I8:I67 E3:E62 chart2
Q8:Q67 H3:H62 chart3
Y8:Y67 K3:K62 chart4Then another 4 charts starts at row 89
A89:A148 B3:B62 chart1
I89:I148 E3:E62 chart2
Q89:Q148 H3:H62 chart3
Y89:Y148 K3:K62 chart4Then another 4 charts start at row 169 to 228
A169:A228 B3:B62 chart1
I169:I228 E3:E62 chart2
Q169:Q228 H3:H62 chart3
Y169:Y228 K3:K62 chart4
and so on down to row 4326There is only one worksheet. Is there anyway to iterate thru each of the charts and make the bar that has “TOTAL” in it’s range black. I need a macro because every month this data will change and i don’t want to have to manually go in and make the approporiate bar black. Thank you.
-
WSHansV
AskWoody LoungerJuly 30, 2002 at 6:06 am #604904My goodness, you don’t believe in making things easy, do you?
I don’t understand why you wanted to refer to another worksheet yesterday. Now you state that there is only one worksheet.
I’d like to go back to the post that started this thread. There, you mentioned that[indent]
The graph is not “attached” to the rows in excel (for various reasons it can’t be done like this).
[/indent]At first, I didn’t question this, and created a solution for you. Now, you keep making it more and more complicated, and I’m starting to think that maybe you should redesign the whole thing. If you just used the names as the X-axis range, it would be much easier.
-
macropod
AskWoody_MVPJuly 31, 2002 at 3:03 am #605104Hi Hans,
I agree with your comments about using the XValues – even if not displayed on the chart they would make it far easier to identify the rows to blacken.
I had a look at the solution you provided in your first post on this topic and noted there’s no code to change a bar back to red if it’s no longer a ‘total’ one. Since the charts are changing each month, this may be important. In that case, you need to change the colouring loop to something like:
‘ Loop through data points
For i = 1 To ser.Points.Count
‘ Get text in cell to right of value
strVal = rng.Cells(i, 2)
‘ Color data points red
Set pnt = ser.Points(i)
pnt.Interior.ColorIndex = 3
‘ Check if TOTAL occurs in text
If InStr(UCase(strVal), “TOTAL”) > 0 Then
‘ Color data point black
pnt.Interior.ColorIndex = 1
End If
Next iCheers
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
-
-
-
-
Viewing 0 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
-
I set up passkeys for my Microsoft account
by
Lance Whitney
59 minutes ago -
AI is for everyone
by
Peter Deegan
5 hours, 17 minutes ago -
Terabyte update 2025
by
Will Fastie
5 hours, 19 minutes ago -
Migrating from Windows 10 to Windows 11
by
Susan Bradley
5 hours, 39 minutes ago -
Lost sound after the upgrade to 24H2?
by
Susan Bradley
15 hours, 21 minutes ago -
How to move 10GB of data in C:\ProgramData\Package Cache ?
by
Alex5723
3 hours, 51 minutes ago -
Plugged in 24-7
by
CWBillow
1 hour, 18 minutes ago -
Netflix, Apple, BofA websites hijacked with fake help-desk numbers
by
Nibbled To Death By Ducks
1 day, 4 hours ago -
Have Copilot there but not taking over the screen in Word
by
CWBillow
1 day, 1 hour ago -
Windows 11 blocks Chrome 137.0.7151.68, 137.0.7151.69
by
Alex5723
2 days, 19 hours ago -
Are Macs immune?
by
Susan Bradley
17 hours, 41 minutes ago -
HP Envy and the Function keys
by
CWBillow
2 days, 3 hours ago -
Microsoft : Removal of unwanted drivers from Windows Update
by
Alex5723
7 hours, 12 minutes ago -
MacOS 26 beta 1 dropped support for Firewire 400/800
by
Alex5723
3 days, 7 hours ago -
Unable to update to version 22h2
by
04om
15 hours, 24 minutes ago -
Windows 11 Insider Preview Build 26100.4482 (24H2) released to Release Preview
by
joep517
3 days, 14 hours ago -
Windows 11 Insider Preview build 27881 released to Canary
by
joep517
3 days, 14 hours ago -
Very Quarrelsome Taskbar!
by
CWBillow
3 days ago -
Move OneNote Notebook OFF OneDrive and make it local
by
CWBillow
4 days, 3 hours ago -
Microsoft 365 to block file access via legacy auth protocols by default
by
Alex5723
3 days, 16 hours ago -
Is your battery draining?
by
Susan Bradley
16 hours, 2 minutes ago -
The 16-billion-record data breach that no one’s ever heard of
by
Alex5723
16 hours, 2 minutes ago -
Weasel Words Rule Too Many Data Breach Notifications
by
Nibbled To Death By Ducks
4 days, 7 hours ago -
Windows Command Prompt and Powershell will not open as Administrator
by
Gordski
9 hours, 47 minutes ago -
Intel Management Engine (Intel ME) Security Issue
by
PL1
3 days, 15 hours ago -
Old Geek Forced to Update. Buy a Win 11 PC? Yikes! How do I cope?
by
RonE22
3 days, 8 hours ago -
National scam day
by
Susan Bradley
2 days, 14 hours ago -
macOS Tahoe 26 the end of the road for Intel Macs, OCLP, Hackintosh
by
Alex5723
3 days, 11 hours ago -
Cyberattack on some Washington Post journalists’ email accounts
by
Bob99
5 days, 8 hours ago -
Tools to support internet discussions
by
Kathy Stevens
3 days, 21 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.