SOLVED

Conditional formatting for x number of days before

%3CLINGO-SUB%20id%3D%22lingo-sub-2099961%22%20slang%3D%22en-US%22%3EConditional%20formatting%20for%20x%20number%20of%20days%20before%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2099961%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20face%3D%22Arial%2C%20%26quot%3BHelvetica%20Neue%26quot%3B%2C%20Helvetica%2C%20sans-serif%22%3EI%20am%20trying%20to%20set%20a%20conditional%20formatting%20for%20an%20%3CSTRONG%3Eexpiration%20date%20field.%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20face%3D%22Arial%2C%20%26quot%3BHelvetica%20Neue%26quot%3B%2C%20Helvetica%2C%20sans-serif%22%3E%20The%20idea%20is%20to%20show%20via%20color%20coding%20(green%2C%20yellow%2C%20and%20red)%20when%20the%20expiration%20date%20is%20approaching%20according%20to%20the%20cell%20(In%20the%20%3CSTRONG%3EE%20column)%20and%20today's%20date.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%3CDIV%20align%3D%22left%22%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20face%3D%22Arial%2C%20%26quot%3BHelvetica%20Neue%26quot%3B%2C%20Helvetica%2C%20sans-serif%22%3EIt%20should%20fill%20green%20when%20the%20date%20in%20the%20field%20is%20equal%20or%20after%20today%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3CDIV%20align%3D%22left%22%3E%3DE3%26gt%3BTODAY()%3CDIV%20align%3D%22left%22%3E%26nbsp%3B%3CDIV%20align%3D%22left%22%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20face%3D%22Arial%2C%20%26quot%3BHelvetica%20Neue%26quot%3B%2C%20Helvetica%2C%20sans-serif%22%3EIt%20should%20fill%20yellow%20when%20the%20date%20in%20the%20field%20is%20less%20than%20today%20and%20less%20than%203%20months%20(90%20days)%20(between%2089%20days%20and%20yesterday)%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3CDIV%20align%3D%22left%22%3E%3DAND(E3%3CTODAY%3E(TODAY()-90))%3CDIV%20align%3D%22left%22%3E%26nbsp%3B%3CDIV%20align%3D%22left%22%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20face%3D%22Arial%2C%20%26quot%3BHelvetica%20Neue%26quot%3B%2C%20Helvetica%2C%20sans-serif%22%3EIt%20should%20fill%20red%20when%20the%20date%20in%20the%20field%20is%20less%20than%203%20months%20(90%20days)%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3CDIV%20align%3D%22left%22%3E%3DE3%26lt%3B%3DTODAY()-90%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20face%3D%22Arial%2C%20%26quot%3BHelvetica%20Neue%26quot%3B%2C%20Helvetica%2C%20sans-serif%22%3EI%20have%20included%20the%20dates%20(including%20%22today's%20date%22)%20as%20reference.%26nbsp%3B%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20face%3D%22Arial%2C%20%26quot%3BHelvetica%20Neue%26quot%3B%2C%20Helvetica%2C%20sans-serif%22%3EI%20added%20the%20C%3CSTRONG%3Eonditional%20Formatting%20Rules%20formula%20in%20the%20cells.%26nbsp%3B%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20face%3D%22Arial%2C%20%26quot%3BHelvetica%20Neue%26quot%3B%2C%20Helvetica%2C%20sans-serif%22%3EI%20also%20included%20the%20%3CSTRONG%3ECorrection%20column%20to%20show%20what%20the%20correct%20color%20should%20be.%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20face%3D%22Arial%2C%20Helvetica%20Neue%2C%20Helvetica%2C%20sans-serif%22%20size%3D%222%22%20color%3D%22%23242729%22%3E%3CFONT%20color%3D%22%23242729%22%3E%3CFONT%20size%3D%222%22%3E%3CFONT%20face%3D%22Arial%2C%20%26quot%3BHelvetica%20Neue%26quot%3B%2C%20Helvetica%2C%20sans-serif%22%3EThe%20colors%20do%20not%20match%20my%20date%20ranges.%3CBR%20%2F%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22uew44IN%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249687iFC2D6B14788F0737%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22uew44IN%22%20alt%3D%22uew44IN%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FTODAY%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2099961%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2100721%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20for%20x%20number%20of%20days%20before%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2100721%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F298909%22%20target%3D%22_blank%22%3E%40Rick151%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20you%20enter%20the%20conditional%20format%20formulas%2C%20remember%20that%20the%20cell%20addresses%20of%20the%20conditional%20format%20formula%20are%20relative%20to%20the%20active%20cell.%20Is%20it%20possible%20you%20had%20cell%20E1%20as%20the%20active%20cell%20when%20you%20entered%20the%20conditional%20formats%3F%20Notice%20how%20your%20formats%20are%20off%20by%202%20rows%20(move%20your%20correct%20column%20up%20two%20cells%20and%20they%20match)%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JMB17_0-1611725346923.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F249722iA40917F7966F729F%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22JMB17_0-1611725346923.png%22%20alt%3D%22JMB17_0-1611725346923.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2106888%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20for%20x%20number%20of%20days%20before%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2106888%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675152%22%20target%3D%22_blank%22%3E%40JMB17%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EI%20had%20tried%20deleting%20the%20top%20rows%20still%20the%20same.%20I%20uploaded%20my%20file.%3C%2FLINGO-BODY%3E
Occasional Contributor

I am trying to set a conditional formatting for an expiration date field. The idea is to show via color coding (green, yellow, and red) when the expiration date is approaching according to the cell (In the E column) and today's date.

It should fill green when the date in the field is equal or after today
=E3>TODAY()
 
It should fill yellow when the date in the field is less than today and less than 3 months (90 days) (between 89 days and yesterday)
=AND(E3<TODAY(),E3>(TODAY()-90))
 
It should fill red when the date in the field is less than 3 months (90 days)
=E3<=TODAY()-90

 

I have included the dates (including "today's date") as reference. 

I added the Conditional Formatting Rules formula in the cells. 

I also included the Correction column to show what the correct color should be.

 

 

The colors do not match my date ranges.

uew44IN

5 Replies

@Rick151 

 

When you enter the conditional format formulas, remember that the cell addresses of the conditional format formula are relative to the active cell. Is it possible you had cell E1 as the active cell when you entered the conditional formats? Notice how your formats are off by 2 rows (move your correct column up two cells and they match)?

 

 

JMB17_0-1611725346923.png

 

@JMB17

I had tried deleting the top rows still the same. I uploaded my file.
best response confirmed by Rick151 (Occasional Contributor)
Solution

@Rick151 so as @JMB17 indicated your reference is wrong.  Your 'Applies to' field is $E:$E which means your top left most cell is E1 but your formulas all use E3 which is why everything is off by 2 rows.  You can change the formulas to use E1 and it will work.

That said, you could also just use the built in conditional formatting:

mtarler_0-1611860027182.png

and then you don't need any cell references.

And alternative solution instead of having 3 conditional formatting rules you can use ICON sets instead:

mtarler_2-1611860169519.png  mtarler_3-1611860242159.png

a different look which may or may not be good for what you want.

 

@Rick151 

 

No, deleting the top rows won't fix it. You have to edit the formulas.

 

The formulas apply to the range E:E and the cell references of your formulas are relative to the top left cell of the 'applies to' range (so cell E1 in this case). Your formulas reference cell E3, which is 2 rows down from cell E1. So, the formula will be looking at the value of E5 when it's evaluating the conditional format of cell E3 (and so on).

 

JMB17_0-1611861064558.png

 

Try changing the formulas to:

Green: =E1>=TODAY()

Yellow: =AND(E1<TODAY(),E1>(TODAY()-90))

Red: =E1<=TODAY()-90

 

 

@mtarler 

 

It all came down to that I was selecting the wrong rule type.

I changed the rule type from Use a formula to determine which cells to format to Format Cells that contain and it worked perfectly.

 

Thanks!