Conditional Format to highlight past and future dates - excel

I have a spreadsheet that has 5 columns of dates the all refer to one key date.
The key date is the date of sign off for a piece of work, the other columns reference that date, and subtract 2, 6, 8, 10 and 14 days to show the dates that each stage needs to be completed by.
The conditional format I want to be able to create needs to take the day (TODAY()) then look across all dates and apply the following format:
If dates in the range are this week, then highlight the cells green
If dates in the range are last week, then highlight the cells amber
If dates in the range are greater than last week, then highlight the cells red
If dates in the range are greater than next week, then highlight the cells light green
Every option I've tried the range only gets one of the formats applied.
The purpose is to allow my team to see at a glance actions that need to be closed because they are either out of date, or just about to be.
Any help is very much appreciated.
Thanks,
Andrew.

You will need to add three conditional format rules to make this happen and each will need to be based on a formula.
Formula to identify dates older than 2 weeks:
=DATEDIF(C12,TODAY(),"d")>14
Formula to identify dates last week:
=AND(DATEDIF(C12,TODAY(),"d")<=14,DATEDIF(C12,TODAY(),"d")>7)
Formula to identify dates this week:
=AND(DATEDIF(C12,TODAY(),"d")<=7,DATEDIF(C12,TODAY(),"d")>0)

Related

Pull named range from cell value

I have a spreadsheet used to generate monthly job cards. I need to set it up so it "knows" which month it's on, and on which day number a Monday falls. To this end I have set it up that each day number for every monday this year is listed. Each line on the daily task jobcard is serial numbered from 1 to 28,30, or 31 dependant on the month, so I have set up a formula to check the serial number for the daily task against the day number of each Monday. It works and I have checked this, but the only issue I have is that the formula (=IF(COUNTIF(MARCH23MON,AJ6)>0,$AK$4,$AK$5)) requires me to change the MARCH23MON to match the range for each month up to 31 times every month.
Is there a way to do something like if the date = the date listed in cell a1, then use the value of cell b2 as the range (i.e. MARCH23MON).
See the screenshot here to see how I have begun to set this out. The date for each month is defined by the user in cell C3 when they generate the job cards for the upcoming month, this is then copied into cell AJ2 and formatted to match the dates in AP3:AP14.
I'd like to have the date defined in AJ2 to define the range the formula in AN6:AN36 uses from those listed in AO3:AO14, so that each month is checked against the relevant range of dates.
I had attempted to just use a vlookup then reference the output in this formula =IF(COUNTIF(MARCH23MON,AJ6)>0,$AK$4,$AK$5) as follows =IF(COUNTIF($AL$2,AJ6)>0,$AK$4,$AK$5) which obviously doesn't work. I tried it as ADDRESS($AL$2) but again no worky. Not sure if it is possible.
Foxfire and Burns And Burns mentioned the CHOOSE function in a comment, and that has resolved this for me. Instead of using the list of range names I am now using CHOOSE
to select the dates of each month's Mondays from individual lists. I get the value of AL2 from a VLOOKUP function.

Excel date based Conditional Format

I have got a license check tracker with dates entered when a check is done in column (E) and a date populates in the cell next to it in column (F) that is 90 days later for when the check must be done by next.
What I am looking for is to make the cells in column (F) with the dates the next license checks must be done, to automatically turn bright red if the date in the cell is within two week of the date you are viewing the sheet.
E
F
Licence Check DATE
License Check Expire
03/11/2021
01/02/2022
04/11/2001
02/02/2002
30/03/1900
03/11/2021
01/02/2022
30/03/1900
Apply conditional formatting to the column with dates you want to format, then choose the Use a formula to determine which cells to format option and use the following formula:
=AND(F2>(TODAY()-14),F2<(TODAY()+14))
This will highlight all dates which are in range between the day which fell 14 days before and the day falling 14 days after TODAY() (assuming today is the day you're viewing the worksheet on).

Excel - count days between two dates per year

I am trying to get the number of days per year between two dates.
The results should look somehow like the following picture
The range between the 2 dates in the 2021 year has 301 days and in the 2022 year has 94 days.
Put this in C2 and copy over:
=MIN(DATE(C1,12,31),$B$2)-MAX(DATE(C1,1,1),$A$2)
Your question isn't entirely easy to understand but what you don't know is in plain sight: Excel represents dates as integer numbers where Jan 1, 1900 is the first day (= 1) and all days from then till now have a unique number. Today is 44261. Tomorrow will be 44262.
Therefore the difference between dates equals [End date] - [Start date], where only one of these two dates is included in the count. [Tomorrow]-[Today] = 1, not 2.
When a worksheet cell is formatted as General Excel will automatically change that format to whatever Excel thinks you have probably entered. If you enter what Excel recognizes as a date the cell format will be changed to Date and if the way you entered the date was by function, such as =TODAY() the cell will display "6/3/2021" using the date format specified in your Windows International settings.
But if you manually change the cell format back to General or Number the display will change to 44262. That's the way you can test if your cell contains a "true" date, with which you can do calculations, or a "fake" date, which is just a text string which is nice to look at but otherwise useless.

Lookup date, return sum of previous 5 days

I am needing a bit of help on a formula which I have been amending for a while now with no success going through vlookups, indexmatches, sumproducts etc.
Basically, on one tab "weekly summary" I have the date contained in cell H2 which will only ever be set to a monday. I need a formula in cell B3 that will look up to a different tab "Raw Data Input" based on this date in cell H2, and return the sum of the values for the previous week (previous 5 amounts using the workdays formula on raw data input tab).
So for instance if this was today, 14th Nov, I would want the sum of the values from 7th-11th Nov.
Is this possible without doing 5 separate vlookups to different dates?
Ps. I will eventually form this into a macro, however as I have a number of tasks to complete before I get to that stage, I would prefer it as a formula, to get everything set up before I start adding VBA.
You can use SUMIFS where your multiple conditions are dates are less than 14th Nov, but greater than 14th Nov - 7
=SUMIFS(A:A,B:B, "<"&$H$2,B:B, ">"&$H$2-7)
Whereby A:A is the sum range, and B:B is the columns with dates.

Conditional format of date where 3 working days greater than cell value

I am trying to adapt a number of forum posts and previous stack questions like this.
Let's say I have a date Column A2, A3, A4 etc.
I want to be able to utilize the WEEKDAY function to evaluate my condition when only in a Weekday and also 3 days greater than the date in Cell A(x).
So far my attempts have failed or I have not got the results I want. Excel is not my strongest point when it comes to conditional formula formatting.
I think it may be something like:
=WEEKDAY(A$2,2) <=5 AND 'My Cell Date' > 3 Days WHERE those 3 days are weekdays.
Also if it is possible, I want it to work like:
If day 1 of 3 is Thursday, day 2 of 3 is Friday and day 3 of 3 is Monday then apply formatting.
Could anyone help me out with this one please?
Edit not from OP to copy clarification from comments:
If the today date is 3 working days greater than the cell date change to red.
Say A2 has a received date and B2 has a completed date. The completed date is my target. Is it 3 working days greater than received.
Was not quite certain of the requirement (but seem to have hit upon an acceptable solution!):
Use =NETWORKDAYS(A2,B2)>2 under Format values where this formula is true: under Use a formula to determine which cells to format in Conditional Formatting.
NETWORKDAYS
Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays.
The syntax is:
NETWORKDAYS(start_date,end_date,holidays)
Dates should be entered by using the DATE function, or as results of other formulas or functions.

Resources