Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-01-2022, 10:15 PM
Kiwi971 Kiwi971 is offline Conditional format  a table cell based on percentage range Windows 10 Conditional format  a table cell based on percentage range Office 2016
Novice
Conditional format  a table cell based on percentage range
 
Join Date: May 2021
Location: United Arab Emirates
Posts: 9
Kiwi971 is on a distinguished road
Default Conditional format a table cell based on percentage range

Hi all,

was wondering if someone was able to help me out?
I want to conditionally format a cell in a table in MS Word based on a percentage range

Red >=91.99%
Amber 92% - 93.99%


Green >=94%

I've read a couple of threads about VBA, but VERY VERY new to it all.

HELP!!!!

Thanks in advance
Reply With Quote
  #2  
Old 10-02-2022, 07:09 AM
macropod's Avatar
macropod macropod is offline Conditional format  a table cell based on percentage range Windows 10 Conditional format  a table cell based on percentage range Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Depending on your requirements, this can be done via field coding or a macro.

However, since you haven't told us anything about the mechanism by which these cells get populated, it's impossible to give any advice specific to your situation.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-02-2022, 01:08 PM
Charles Kenyon Charles Kenyon is offline Conditional format  a table cell based on percentage range Windows 11 Conditional format  a table cell based on percentage range Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

You could also incorporate an Excel part in your document. Conditional formatting is far easier in Excel.
Reply With Quote
  #4  
Old 10-02-2022, 11:28 PM
Kiwi971 Kiwi971 is offline Conditional format  a table cell based on percentage range Windows 10 Conditional format  a table cell based on percentage range Office 2016
Novice
Conditional format  a table cell based on percentage range
 
Join Date: May 2021
Location: United Arab Emirates
Posts: 9
Kiwi971 is on a distinguished road
Default Conditional format a table cell based on percentage range

Quote:
Originally Posted by macropod View Post
Depending on your requirements, this can be done via field coding or a macro.

However, since you haven't told us anything about the mechanism by which these cells get populated, it's impossible to give any advice specific to your situation.
Sorry, I have a document that I've mail merged from an excel document.
The word document has 4 or 5 tables.
I want to apply a conditional format to table 4 row 2 (only one cell)

In the cell below YOUR CHILD’S ATTENDANCE PERCENTAGE IS...
There is a percentage (merged field) this cell is what I want to conditionally format where the cell is filled with colour (according to the outline below).

RED = <91.99%
AMBER = >=92% <=93.99%
GREEN = >94%
Attached Files
File Type: docx SAMPLE.docx (26.6 KB, 3 views)
Reply With Quote
  #5  
Old 10-03-2022, 05:42 AM
macropod's Avatar
macropod macropod is offline Conditional format  a table cell based on percentage range Windows 10 Conditional format  a table cell based on percentage range Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In which case you don't need a macro - all you need is some field coding. See Conditionally Format Mailmerge Output, Conditionally Shade Table Cells, and Conditionally Colour/Shade Numeric Output Ranges in the Mailmerge Tips & Tricks 'Sticky' thread at the top on the Mailmerge forum, to which I've moved your thread. Any of those approaches can be leveraged to achieve the desired result.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 10-03-2022, 06:53 AM
Kiwi971 Kiwi971 is offline Conditional format  a table cell based on percentage range Windows 10 Conditional format  a table cell based on percentage range Office 2016
Novice
Conditional format  a table cell based on percentage range
 
Join Date: May 2021
Location: United Arab Emirates
Posts: 9
Kiwi971 is on a distinguished road
Default

Is there a way I can add that to the field coding I have in there already?
I currently have {=«Percent»*100 \# 0.00%}.

So based on whatever this results spits out, I want to shade the cell according to the % range I mentioned earlier?

Thanks a million for all the support
Reply With Quote
  #7  
Old 10-03-2022, 03:06 PM
macropod's Avatar
macropod macropod is offline Conditional format  a table cell based on percentage range Windows 10 Conditional format  a table cell based on percentage range Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Kiwi971 View Post
Is there a way I can add that to the field coding I have in there already?
I currently have {=«Percent»*100 \# 0.00%}
No, it's not that simple. What you need is something like:

{QUOTE {SET Val {={MERGEFIELD Percent}*100 \# 0.00 }}{=INT(Val-93) \# "'→↵
{Val}
→'
;' →↵
{Val}
→'
;' →↵
{Val}
→'
"}"}}%
where the relevant highlight colours are applied to the field coding according to the colouring (we can't do highlighting here) and each cell to be shaded has:
• margins set to 0 all round
• paragraph formatting with a single right-aligned tab-stop set to at least the cell width.

Note: The spaces shown in the field constructions are all required. Instead of the → and ↵ symbols shown above, you should use real tabs and line/paragraph breaks, respectively.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 10-03-2022, 11:25 PM
Kiwi971 Kiwi971 is offline Conditional format  a table cell based on percentage range Windows 10 Conditional format  a table cell based on percentage range Office 2016
Novice
Conditional format  a table cell based on percentage range
 
Join Date: May 2021
Location: United Arab Emirates
Posts: 9
Kiwi971 is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
No, it's not that simple. What you need is something like:

{QUOTE {SET Val {={MERGEFIELD Percent}*100 \# 0.00 }}{=INT(Val-93) \# "'→↵
{Val}
→'
;' →↵
{Val}
→'
;' →↵
{Val}
→'
"}"}}%
where the relevant highlight colours are applied to the field coding according to the colouring (we can't do highlighting here) and each cell to be shaded has:
• margins set to 0 all round
• paragraph formatting with a single right-aligned tab-stop set to at least the cell width.

Note: The spaces shown in the field constructions are all required. Instead of the → and ↵ symbols shown above, you should use real tabs and line/paragraph breaks, respectively.
Thanks so much for your support, let me have a go at inputting this. I'm very new at this, so will probably come back with questions. First time user!
Reply With Quote
Reply

Tags
conditional formatting, ms word, tables

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional format  a table cell based on percentage range How to conditional format a table cell in word based on it's value. JulianS96 Word VBA 9 10-20-2021 02:25 AM
Need Conditional based percentage formula! jocky6688 Excel 5 03-15-2021 12:35 AM
Conditional Formatting on cell values outside of a designated range based on category denoted in key interntime Excel 3 05-21-2018 10:15 PM
Floating date range on a conditional format Old Excel 2 06-22-2017 08:32 AM
Conditional format a button based off a value in a field Triscia Misc 0 03-11-2015 11:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft