Weeknum Function

Chris Waller

Board Regular
Joined
Jan 18, 2009
Messages
183
Office Version
  1. 365
Platform
  1. Windows
I have an Excel 2010 Spreadsheet which contains a number of random dates in column P. What I am trying to do is highlight the row if the date is within 4 weeks of the current date, I would also like to highlight the dates in a different colour if the date is within 3 weeks of the current date.

I believe the best formula to use would be to use the Weeknum Function. Not having used this formula previously would appreciate it if someone could help with a conditional format or some VBA which would achieve the desired outcome. TIA
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi Chris,

would it be acceptable to set the criteria as follows:set this for the entire row (assuming your data starts from row 1 downwards. Adjust as needed)

$P1<(Today()+28)
For the second question, I'd go with

P1<(Today()+21)

Make sure that the last rule has higher priority in the conditional format overview.
 
Upvote 0
Hi Noodleski,

Thanks for your prompt reply, I don't think your suggestion will work as needed. The reason is that if I run this report on a Monday, the formula will only pick up items that are exactly four weeks old rather than highlighting ALL the items for that week that will be four weeks old and the similar problem will exist for the items that are three weeks old. Hence the reason why I suggested the Weeknum formula. Thanks again.
 
Upvote 0
Hi Noodleski,

Thanks for your prompt reply, I don't think your suggestion will work as needed. The reason is that if I run this report on a Monday, the formula will only pick up items that are exactly four weeks old rather than highlighting ALL the items for that week that will be four weeks old and the similar problem will exist for the items that are three weeks old. Hence the reason why I suggested the Weeknum formula. Thanks again.
Fair enough. Not a native speaker, I missed that nuance.
Try
week($P1)<(week(today())+4)

and
week(P1)<week(today())+3)< html=""></week(today())+3)<>
 
Last edited:
Upvote 0
You'll have problems with WEEKNUM if your date is near the beginning of the year. Maybe try eg:

=(P1-WEEKDAY(P1,1)+1)>=((TODAY()-28)-WEEKDAY(TODAY(),1)+1)
 
Upvote 0
Andrew,

Thanks for that, but it still doesn't appear to work. It may be me, but when I tried this on my Spreadsheet the formula appears to gives False when the date is in the past. What I am trying to do is when a date is upcoming I need to take action at 4 weeks prior to the date in column P. I then need to know when it is three weeks prior to the date in column P, but after that I'm not interested as the action should have been taken at these two points in time. TIA
 
Upvote 0
I think the first suggestion by Noodleski is the way to go.

Thanks for your prompt reply, I don't think your suggestion will work as needed. The reason is that if I run this report on a Monday, the formula will only pick up items that are exactly four weeks old
That's not a correct assessment of what that formula will do.

It will ADD 21 or 28 days (3 or 4 weeks) to the current date.
If the Date in P1 is PRIOR to that date, the formula will be TRUE
 
Last edited:
Upvote 0

Forum statistics

Threads
1,222,018
Messages
6,163,423
Members
451,835
Latest member
kristianb63

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