IF Cell Equals a value and has a date in other Cell then Green?

Tony J

New Member
Joined
Oct 25, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Web
I hope someone will be able to help me

In the attached screenshot you can see that the scope of work (column D) there is a list of transport jobs, if they have the necessary training in columns PMVA, FREC 3, FREC 4, ACA, DCA (Column E to I) which would be a date and it greater than today then I would like the cell in column to eith say Green or show green

I had something like this in mind - but know it would be a lot more complex than this;

=IF(AND(D4="Mental Health",E4>TODAY()),"Green",""))

This would return Green if the date was in a weeks time - but I cannot seem to find a way to add the other rules;

Mental Health needs a PMVA date greater than today to be green
HDU needs a FREC3 and FREC4 date greater than today to be green
PTS needs a FREC3, FREC4 and ACA date greater today to be green
but if PTS has a date in DCA it should be orange
Courier and Staff Transport need all dates to be greater than today to be green

Is this possible or are there too many nested IFs, ANDs, ORs in the formula for it to be possible

This is my first time posting so I hope I have posted correctly and it makes sense
 

Attachments

  • Screenshot (2).png
    Screenshot (2).png
    11.6 KB · Views: 80

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
you can use conditional formatting to actually change the colour
Book3
ABCDEFG
1scope of workPMVAFREC 3FREC 4ACADCAColour
2Mental health12/25/20green
3HDU12/25/201/23/21green
4PTS12/25/201/23/211/1/21green
5Staff Transport12/25/201/23/211/1/211/1/21green
6Courier12/25/201/23/211/1/211/1/21green
7PTS1/1/18orange
Sheet1
Cell Formulas
RangeFormula
G2:G7G2=IF(AND(A2="PTS",F2<>""),"orange",IF(OR(AND(A2="mental Health",B2>TODAY()),AND(A2="HDU",C2>TODAY(),D2>TODAY()),AND(A2="PTS",C2>TODAY(),D2>TODAY(),E2>TODAY()),AND(A2="Courier",C2>TODAY(),D2>TODAY(),E2>TODAY(),F2>TODAY()),AND(A2="staff transport",C2>TODAY(),D2>TODAY(),E2>TODAY(),F2>TODAY())),"green",""))
 
Upvote 0
Thanks I will give it a go when I get in the office tomorrow - much appreciated
 
Upvote 0
you are welcome , I have also added a conditional format to colour the rows
i had trouble adding the green all in 1 formula - not sure why, so spilt out to 2 formulas for green


Book3
ABCDEFG
1scope of workPMVAFREC 3FREC 4ACADCAColour
2Mental health12/25/20green
3HDU12/25/201/23/21green
4PTS12/25/201/23/211/1/21green
5Staff Transport12/25/201/23/211/1/211/1/21green
6Courier12/25/201/23/211/1/211/1/21green
7PTS1/1/18orange
8 
Sheet1
Cell Formulas
RangeFormula
G2:G8G2=IF(AND(A2="PTS",F2<>""),"orange",IF(OR(AND(A2="mental Health",B2>TODAY()),AND(A2="HDU",C2>TODAY(),D2>TODAY()),AND(A2="PTS",C2>TODAY(),D2>TODAY(),E2>TODAY()),AND(A2="Courier",C2>TODAY(),D2>TODAY(),E2>TODAY(),F2>TODAY()),AND(A2="staff transport",C2>TODAY(),D2>TODAY(),E2>TODAY(),F2>TODAY())),"green",""))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A:FExpression=AND($A1="PTS",$F1<>"")textYES
A:FExpression=OR(AND($A1="Courier",$C1>TODAY(),$D1>TODAY(),$E1>TODAY(),$F1>TODAY()),AND($A1="staff transport",$C1>TODAY(),$D1>TODAY(),$E1>TODAY(),$F1>TODAY()))textNO
A:FExpression=OR(AND($A1="mental Health",$B1>TODAY()),AND($A1="HDU",$C1>TODAY(),$D1>TODAY()),AND($A1="PTS",$C1>TODAY(),$D1>TODAY(),$E1>TODAY()))textNO
 
Upvote 0
Brilliant. I wish I had the capabilty to do this. This worked just as I had asked for but when I went back and showed my boss he changed his mind on the rules :( and said that he wanted it to be green if the date was only one of the training courses for example;

Mental Health only needs PMVA
HDU could be FREC3 or FREC4
Staff Transport could be any
Courier could be any
PTS could be FREC3 or FREC4 or ACA

I thought it would just be as simple as adding the bolded lettering below - but it was not

=IF(AND(A2="PTS",F2<>""),"orange",IF(OR(AND(A2="mental Health",B2>TODAY()),AND(A2="HDU",C2>TODAY(),D2>TODAY()),OR(AND(A2="PTS",C2>TODAY(),D2>TODAY(),E2>TODAY()),OR(AND(A2="Courier",C2>TODAY(),D2>TODAY(),E2>TODAY(),F2>TODAY()),OR(AND(A2="staff transport",C2>TODAY(),D2>TODAY(),E2>TODAY(),F2>TODAY())),"green",""))

Is it possible to have nested / Muliple OR queries?
 
Upvote 0
OK
OLD RULES
GREEN
Mental Health needs a PMVA date greater than today to be green
HDU needs a FREC3 AND FREC4 date greater than today to be green
PTS needs a FREC3 AND FREC4 AND ACA date greater today to be green
Courier and Staff Transport need all dates to be greater than today to be green

ORANGE
but if PTS has a date in DCA it should be orange

SO the NEW rules for Orange - NO CHANGE
NEW RULES
for GREEN now are
Mental Health only needs PMVA, NO CHANGE
HDU could be FREC3 or FREC4 - THIS is NOW an OR rather than an AND
Staff Transport could be any - nolonger ALL - BUT ANY of the dates - so AN OR
Courier could be any - nolonger ALL - BUT ANY of the dates - so AN OR
PTS could be FREC3 OR FREC4 OR ACA

IS that correct?

OR(AND(A2="PTS",C2>TODAY(),D2>TODAY(),E2>TODAY()),
you need the OR and AND reversed
so the AND is A2 = PTS AND , any of the other columns so an OR

AND(A2="PTS",OR(C2>TODAY(),D2>TODAY(),E2>TODAY()))
Which means A2 MUST have PTS AND anyone of the C2,D2,E2 MUST be > then today
 
Upvote 0
OK
OLD RULES
GREEN
Mental Health needs a PMVA date greater than today to be green
HDU needs a FREC3 AND FREC4 date greater than today to be green
PTS needs a FREC3 AND FREC4 AND ACA date greater today to be green
Courier and Staff Transport need all dates to be greater than today to be green

ORANGE
but if PTS has a date in DCA it should be orange

SO the NEW rules for Orange - NO CHANGE
NEW RULES
for GREEN now are
Mental Health only needs PMVA, NO CHANGE
HDU could be FREC3 or FREC4 - THIS is NOW an OR rather than an AND
Staff Transport could be any - nolonger ALL - BUT ANY of the dates - so AN OR
Courier could be any - nolonger ALL - BUT ANY of the dates - so AN OR
PTS could be FREC3 OR FREC4 OR ACA

IS that correct?

OR(AND(A2="PTS",C2>TODAY(),D2>TODAY(),E2>TODAY()),
you need the OR and AND reversed
so the AND is A2 = PTS AND , any of the other columns so an OR

AND(A2="PTS",OR(C2>TODAY(),D2>TODAY(),E2>TODAY()))
Which means A2 MUST have PTS AND anyone of the C2,D2,E2 MUST be > then today
Thank you for your reply

Sorry was out of the office all yesterday and never had time to reply before I left Tuesday.

What you have descrived above is correct but to make it easier I have split PTS to PTS walker and PTS Non walker - like so;

If Mental Health, PMVA = Green
If HDU OR FREC3 OR FREC4 = Green
If PTS - Non Walker, FREC3 OR FREC 4 OR ACA = Green
If PTS Walker, DCA = Orange
If Courier any of them = Green
If Staff taxi any of them = Green

Is this possible if multi OR commands?
 
Upvote 0
Book1
ABCDEFG
1scope of workPMVAFREC 3FREC 4ACADCAnew rule
2Mental health12/25/20green
3HDU12/25/201/23/21green
4PTS - Non walker1/1/21green
5Staff Transport1/1/21green
6Courier1/1/211/1/21green
7PTS walker1/1/18orange
Sheet1
Cell Formulas
RangeFormula
G2:G7G2=IF(AND(A2="PTS Walker",F2<>""),"orange",IF(OR(A2="mental Health",AND(A2="HDU",OR(C2>TODAY(),D2>TODAY())),AND(A2="PTS - Non Walker",OR(C2>TODAY(),D2>TODAY(),E2>TODAY())),AND(A2="Courier",OR(C2>TODAY(),D2>TODAY(),E2>TODAY(),F2>TODAY())),AND(A2="staff transport", OR(C2>TODAY(),D2>TODAY(),E2>TODAY(),F2>TODAY()))),"green",""))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A:GExpression=AND($A1="PTS Walker",$F1<>"")textNO
A:GExpression=OR(AND($A1="Courier",OR($C1>TODAY(),$D1>TODAY(),$E1>TODAY(),$F1>TODAY())),AND($A1="staff transport", OR($C1>TODAY(),$D1>TODAY(),$E1>TODAY(),$F1>TODAY())))textNO
A:GExpression=OR($A1="mental Health",AND($A1="HDU",OR($C2>TODAY(),$D1>TODAY())),AND($A1="PTS - Non Walker",OR($C1>TODAY(),$D1>TODAY(),$E1>TODAY())))textNO
 
Upvote 0
Thank you - I think you have nearly cracked it for me

I am going to leave the conditional formatting for now and return to your answer when I am happy the new way of reporting training is happening

Is there something missing on the H2:H7 range for Mental Health as that is the only one now that does not seem to be working - I cannot see B2 in the formula ... then if I try to add it messes up the other returns incorrectly

Original Formula


=IF(AND(A2="PTS",F2<>""),"orange",IF(OR(AND(A2="mental Health",B2>TODAY()),AND(A2="HDU",C2>TODAY(),D2>TODAY()),AND(A2="PTS"

My change to add Mental Health (B2)

=IF(AND(A2="PTS Walker",F2<>""),"orange",IF(OR(A2="mental Health",B2>TODAY(),AND

although as I mentione my way does not seem to work
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,623
Latest member
Techenthusiast

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