Color based on No. Days

Johnboy28

Board Regular
Joined
Jun 22, 2013
Messages
198
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
Platform
  1. Windows
Can anyone help - Based on the Production Date and code and today() Date - Need a formula to work out the "No. Days" over and Under and enter the colour (Red, Amber & Green based on table
Happy for you to change the format of the "No.Days" for formula to work

CodeColourNo. Days
72040Red37 Over
72040Amber37
72040Green35 Under
70559Red46 Over
70559Amber46
70559Green44 Under
73307Red35 Over
73307Amber35
73307Green33 Under
70059Red35 Over
70059Amber35
70059Green33 Under
Production DateCodeColour
14/05/2472040??
15/05/2472040
20/05/2473307
21/05/2470059
21/05/2473307
20/05/2472040
22/05/2470059
22/05/2473307
21/05/2472040
23/05/2470059
22/05/2472040
 
Thank for all your help. I copied the Mini worksheet you did and pasted into my sheet and it all worked. Not sure what I did wrong. All good now. Thanks again. Appreciate it.
I noticed the formula is not working correctly. See below example

CodeColourColourColour
72040Red37>Amber37Green36<
70559Red46>Amber46Green45<
73307Red35>Amber35Green34<
70059Red35>Amber35Green34<
CodeReference Days
7204037
7055946
7330735
7005935
Today:1/06/2024
Production DateCodeDays diffColor Calc
20/04/20247204042GreenShould be red over 37 days
25/04/20247204037GreenShould be Amber 37 days
14/05/20247055918Greencorrect
14/04/20247330748Redcorrect
14/05/20247005918#N/Ashould be green
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I'm sorry, the rules still work as my earlier post and get the results you say you expect.
Please do as I do and make calculation columns for each conditional format color to test your work.

Book1
ABCDEFGHIJK
1CodeColourNo. DaysCodeReference Days
270059Amber35357005935
370059Green0347055946
470059Red355007204037
570559Amber46467330735
670559Green045
770559Red46500
872040Amber3737
972040Green036
1072040Red37500
1173307Amber3535
1273307Green034
1373307Red35500
14ConditionalConditionalConditional
15Today:2024-06-01FormattingFormattingFormatting
16RuleRuleRule
17Production DateCodeDays diffGreenAmberRed
182024-05-137204019GreenTRUEFALSEFALSE
192024-04-087204054RedFALSEFALSETRUE
202024-02-0473307118RedFALSEFALSETRUE
212024-05-217005911GreenTRUEFALSEFALSE
222024-04-247330738RedFALSEFALSETRUE
232024-04-237204039RedFALSEFALSETRUE
242024-05-31700591GreenTRUEFALSEFALSE
252024-05-30733072GreenTRUEFALSEFALSE
262024-04-137204049RedFALSEFALSETRUE
272024-05-25700597GreenTRUEFALSEFALSE
282024-03-287204065RedFALSEFALSETRUE
292024-02-0872040114RedFALSEFALSETRUE
302024-04-287204034GreenTRUEFALSEFALSE
312024-04-157330747RedFALSEFALSETRUE
322024-05-107055922GreenTRUEFALSEFALSE
332024-05-31733071GreenTRUEFALSEFALSE
342024-05-027204030GreenTRUEFALSEFALSE
352024-03-117005982RedFALSEFALSETRUE
362024-05-047330728GreenTRUEFALSEFALSE
372024-04-167204046RedFALSEFALSETRUE
382024-02-0770059115RedFALSEFALSETRUE
392024-05-29720403GreenTRUEFALSEFALSE
402024-05-197204013GreenTRUEFALSEFALSE
412024-02-0972040113RedFALSEFALSETRUE
422024-05-31733071GreenTRUEFALSEFALSE
432024-05-087005924GreenTRUEFALSEFALSE
442024-02-1273307110RedFALSEFALSETRUE
452024-05-067204026GreenTRUEFALSEFALSE
462024-04-207005942RedFALSEFALSETRUE
472024-05-217330711GreenTRUEFALSEFALSE
482024-05-137204019GreenTRUEFALSEFALSE
492024-04-267005936RedFALSEFALSETRUE
502024-03-227204071RedFALSEFALSETRUE
512024-05-31733071GreenTRUEFALSEFALSE
522024-05-197005913GreenTRUEFALSEFALSE
532024-03-277330766RedFALSEFALSETRUE
54
55
56Expected Color
57Production DateCodeDays diffColor Calc
582024-04-207204042Red42GreenShould be red over 37 daysRed
592024-04-257204037Amber37GreenShould be Amber 37 daysAmber
602024-05-147055918Green18GreencorrectGreen
612024-04-147330748Red48RedcorrectRed
622024-05-147005918Green18#N/Ashould be greenGreen
Sheet3
Cell Formulas
RangeFormula
D18:D53,D58:D62D18=$C$15-B18
E18:E53,E58:E62E18=SWITCH(SIGN(($C$15-B18)-LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)),-1,"Green",0,"Amber",1,"Red")
I18:I53I18=($C$15-B18)<LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)
J18:J53J18=($C$15-B18)=LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)
K18:K53K18=($C$15-B18)>LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B18:B53,B58:B62Expression=($C$15-B18)>LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)textNO
B18:B53,B58:B62Expression=($C$15-B18)=LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)textNO
B18:B53,B58:B62Expression=($C$15-B18)<LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)textNO
 
Last edited:
Upvote 0
I'm sorry, the rules still work as my earlier post and get the results you say you expect.
Please do as I do and make calculation columns for each conditional format color to test your work.

Book1
ABCDEFGHIJK
1CodeColourNo. DaysCodeReference Days
270059Amber35357005935
370059Green0347055946
470059Red355007204037
570559Amber46467330735
670559Green045
770559Red46500
872040Amber3737
972040Green036
1072040Red37500
1173307Amber3535
1273307Green034
1373307Red35500
14ConditionalConditionalConditional
15Today:2024-06-01FormattingFormattingFormatting
16RuleRuleRule
17Production DateCodeDays diffGreenAmberRed
182024-05-137204019GreenTRUEFALSEFALSE
192024-04-087204054RedFALSEFALSETRUE
202024-02-0473307118RedFALSEFALSETRUE
212024-05-217005911GreenTRUEFALSEFALSE
222024-04-247330738RedFALSEFALSETRUE
232024-04-237204039RedFALSEFALSETRUE
242024-05-31700591GreenTRUEFALSEFALSE
252024-05-30733072GreenTRUEFALSEFALSE
262024-04-137204049RedFALSEFALSETRUE
272024-05-25700597GreenTRUEFALSEFALSE
282024-03-287204065RedFALSEFALSETRUE
292024-02-0872040114RedFALSEFALSETRUE
302024-04-287204034GreenTRUEFALSEFALSE
312024-04-157330747RedFALSEFALSETRUE
322024-05-107055922GreenTRUEFALSEFALSE
332024-05-31733071GreenTRUEFALSEFALSE
342024-05-027204030GreenTRUEFALSEFALSE
352024-03-117005982RedFALSEFALSETRUE
362024-05-047330728GreenTRUEFALSEFALSE
372024-04-167204046RedFALSEFALSETRUE
382024-02-0770059115RedFALSEFALSETRUE
392024-05-29720403GreenTRUEFALSEFALSE
402024-05-197204013GreenTRUEFALSEFALSE
412024-02-0972040113RedFALSEFALSETRUE
422024-05-31733071GreenTRUEFALSEFALSE
432024-05-087005924GreenTRUEFALSEFALSE
442024-02-1273307110RedFALSEFALSETRUE
452024-05-067204026GreenTRUEFALSEFALSE
462024-04-207005942RedFALSEFALSETRUE
472024-05-217330711GreenTRUEFALSEFALSE
482024-05-137204019GreenTRUEFALSEFALSE
492024-04-267005936RedFALSEFALSETRUE
502024-03-227204071RedFALSEFALSETRUE
512024-05-31733071GreenTRUEFALSEFALSE
522024-05-197005913GreenTRUEFALSEFALSE
532024-03-277330766RedFALSEFALSETRUE
54
55
56Expected Color
57Production DateCodeDays diffColor Calc
582024-04-207204042Red42GreenShould be red over 37 daysRed
592024-04-257204037Amber37GreenShould be Amber 37 daysAmber
602024-05-147055918Green18GreencorrectGreen
612024-04-147330748Red48RedcorrectRed
622024-05-147005918Green18#N/Ashould be greenGreen
Sheet3
Cell Formulas
RangeFormula
D18:D53,D58:D62D18=$C$15-B18
E18:E53,E58:E62E18=SWITCH(SIGN(($C$15-B18)-LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)),-1,"Green",0,"Amber",1,"Red")
I18:I53I18=($C$15-B18)<LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)
J18:J53J18=($C$15-B18)=LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)
K18:K53K18=($C$15-B18)>LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B18:B53,B58:B62Expression=($C$15-B18)>LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)textNO
B18:B53,B58:B62Expression=($C$15-B18)=LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)textNO
B18:B53,B58:B62Expression=($C$15-B18)<LOOKUP($C18,$F$2:$F$5,$G$2:$G$5)textNO
Thank you . I have it all working now. Thank you so much for your help.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top