If you want 20 days instead of 15 then change the 15 to 20. If you want to ignore holidays from the calculation, then omit the range at the end. Like this:
Sorry I just thought of that i made a wrong scenario.
I actually need to include the W28:W999. This is a holiday we have in the office.
I need the result to falls on the weekdays not on the weekend nor the holidays thats on the W column because I cant set schedule for the weekdays. Id my results falls on Sunday then my result should be the Monday instead
If you do not want to type your holidays in column W, then =IF(E3="","",WORKDAY(E3,20,{"date1","date2"...})), replacing date1 with the 1st holiday date, date2 2nd etc.
I have attached the workshseet here. I using 5 days return to make sure as a sample.
I just find out that if we use the return date from today, if its falls on the weekend or holiday then, we need to use the weekend before not the forward weekdays.
Let say today is 03/26/24 so if we count the 5 then the result is 03/31/24 (Sunday). My return should be 03/29/24 to fall back to weekdays (Not 04/02/24).
Another sample, if I enter the date for 04/02/24 then the result should be 04/05/24 (not 04/08/024)
Suppose cell A1 contains a date.
The date after adding 5 days is: A1+5.
If you want A1+5, and if it falls on a weekend or a holiday, and you want to move it to the nearest weekday, there's a trick:
Increase A1+5 by 1 day (A1+6), then move it back 1 day using the WORKDAY function.
If A1+5 is a weekday, nothing will change. But if it falls on a weekend or a holiday, it will be moved back by 1 working day.
If return date falls on a weekend or a holiday and you want to deem the next available working day as the return date, e.g. return date on 6th January (Sat), the next working day is 8th January (not a holiday), then:
5 days from return date (not counting return date as 1 day):
=WORKDAY(WORKDAY(E3-1,1,W28:W907),5,W28:W907)
5 days from return date (counting return date as 1 day):
=WORKDAY(WORKDAY(WORKDAY(E3-1,1,W28:W907),5,W28:W907),-1,W28:W907)
Ok... I came out with something that does work for me. Everything was perfect as I ran or entering the date in E3 but when I enter 02/20/24 and it appears 02/25/24 which is weekend. It should select the 02/26/24. Is this because there is a 29 days in February?
Here is the new created worksheet. This sample has 5 days
Hello everyone,
I really need to finish this project. But it seems I am having trouble getting what i am trying to accomplish.
In my worksheet I added a picture where it supposed to have the result.
5 Calendar day from 2/20/24 iis 2/26/2024
5 calendar day from 2/21/24 is 2/26/2024
5 caelndar day from 2/22/24 is 2/27/2024
5 calendar day from 2/23/24 is 2/28/2024
but in the worksheet it not getting what it supposed to be.
Please fix the formula or maybe change the formula to make it happen.
Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
MS-Off Ver
MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
Posts
80,836
Re: 20 days - Return Date from the Calendar days
Can you to modify the code.
It's a FORMULA, not code, so I've moved the thread out of the VBA section and into the Formulas & Functions section.
Ali Enthusiastic self-taught user of MS Excel who's always learning! Don't forget to say "thank you" in your thread to anyone who has offered you help.
You can reward them by clicking on * Add Reputation below their user name on the left, if you wish. Forum Rules (updated August 2023): please read them here.
Hi
If u count from 2/20 then 2/21, 2/22, 2/23, 2/24, 2/25 then its 2/25 but because 2/25 is sunday then i want to fall on 2/26
now
count from 2/21 then 2/22, 2/23, 2/24, 2/25, 2/26 so it is 2/26 because is a good weekday.
I want 5 dates to fall on weekdays not weekends or the dates thatbis located in sheet2.
Originally Posted by RJ1969
Hello everyone,
5 Calendar day from 2/20/24 iis 2/26/2024
5 calendar day from 2/21/24 is 2/26/2024
5 caelndar day from 2/22/24 is 2/27/2024
5 calendar day from 2/23/24 is 2/28/2024
Originally Posted by josephteh
Sorry to say, Quang, your formula is not foolproof - please see attached workbook.
Hi JT, I notice that the OP doesn't mention wanting to work 5 consecutive days, starting from a specific day; rather, they want to work 5 calendar days in total. However, if the end date falls on a weekend or holiday, it will be adjusted to the next weekday.
That is what my formula did
Hello,
Haven't resolved this issue yet.
I need a formula that if I enter date in E3 the result should show (see below).
5 calendar days from 02/20/24 is 02/26/24
5 Calendar days from 02/21/24 is 02/26/24
5 Calendar days from 02/22/24 is 02/27/24
5 Calendar days from 02/23/24 is 02/28/24
Sheet2 is the dates our office are closed.
At the attachment worksheet if I enter 02/20 result is 02/26/24 which is correct.
But if I enter 02/21/24 is 02/27/24 is incorrect and if I enter 02/22 result is 02/28/24 is also incorrect.
I need the formula where all the dates should be resulted as I wished for.
I think your expected answer for the 20th is incorrect. Please explain WHY you think it should be the 26th.
Try:
=WORKDAY.INTL(E3,5,"0000000",Sheet2!$A$1:$A$42)
Glenn
None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.
Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh
Still not working as it supposed to have a result.
Ok... let me try.
If I enter 02/20/24 in E3, if you count start from 21,22,23,24,25 the 5 count day 02/25/24 but since 02/25/24 is not a good because its Sunday (our office closed on weekend) then the result should show 02/26/24.
Now, If I enter 02/21/24, if you count start from 22,23,24,25,26 the 5th day count is 02/26/24 it's a good day because our office is open.
Lastly, if I enter 02/14/24, if you start counting from 15,16,17,18,19 the 5 days calendar is the 19th but since the 19th is holiday (I have the office holiday in Sheet2) then it should follow the next day the 02/20/24.
So I tried this formula and replaced Glenn's formula but I still not getting the result that I wish for.
In my worksheet I sent there is a calendar.
Try to enter 02/21/24 and start counting from Feb. 22,23,24,25,26 the 5th day is 02/26/24 which is a good day. Our office is closed on weekends and holidays(Sheet2).
No, not really. If your office is closed on the Sunday ( 02/25/24 ), you need to exclude it from all the calculations, not just the first one. It's not a working day, regardless of whether or not the count lands on it.
How can it be excluded but included in counting the days? It doesnt make any sense to me, so Im going to take a step back and let someone else have a go.
What I meant is that when we count days from the day we start, we do include counting the weekends and holidays. But if it falls the 5th day on weekends or holidays then we have to use the following weekday.
ok... I tried it and it worked but I Tried to enter 2/13/24 and it appears 02/19/24 (Holiday - Sheet2) supposedly 02/20/22. Tried to enter 04/15/24 and it appears 04/20/24 (Saturday) it supposed to appear 04/22/24. But some of the days appears ok. You can try to enter in the sample worksheet I sent previously and you will see what it does.
Hi Bebo
The formula is not giving the result as i want it.
TMS formula is actually guving me the way I want it except the 2/14 and and 4/15 entry that still giving me the saturday and holiday result as I noticed when I did an entry on those dates.
What I meant is that when we count days from the day we start, we do include counting the weekends and holidays. But if it falls the 5th day on weekends or holidays then we have to use the following weekday.
Hi Bebo,
I apologize. Your formula works perfect! I am not sure what happened because when I tried it did not work before. But I gave it a try and it worked perfect. Thank you so much.
Can I request just very last thing. This will work for the other worksheet. I have two worksheet I am working on. One worksheet has been resolved with your formula.
My other worksheet it's pretty much the same but if falls Monday-Thursday, I want the result to be the following Friday.
example: 04/15/24 result is 04/22/24 (on your code) then the following Friday is 04/26/24. In otherwords, anything tha will falls on M-Thursday then it should be Friday. But if falls Friday (Holiday) then the good following Friday. I think there is a Friday that is holiday in sheet2
TMS, thank you for your comment, it's true that WORKDAY.INTL isn't available in Excel 2010.
@RJ1969
in that case, using a UDF is also a good choice.
PHP Code:
Option Explicit Function Fri(cell As Double, num As Integer) As Date Dim i&, n&, m&, c&, dat As Date, dat2 As Date dat = cell + num m = Array(5, 4, 3, 2, 1, 0, 6)(Weekday(dat) - 1) dat = dat + m c = WorksheetFunction.CountIf(Worksheets("Sheet2").Columns(1), dat) If c = 0 Then Fri = dat Else Do i = i + 1 Fri = dat + i * 7 If Weekday(Fri) = 6 Then Exit Function Loop Until i = 100 End If End Function
If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
Bookmarks