ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Workday - Saturdays Included - Holidays Excluded (https://www.excelbanter.com/excel-worksheet-functions/65976-workday-saturdays-included-holidays-excluded.html)

Chuy

Workday - Saturdays Included - Holidays Excluded
 

PLEASE I NEED YOUR HELP As Soon As Possible!! Hope You Can Help Me...
Just Like The Function Workday But Including Saturdays
--------------------

I Require The Date as a Output of The Function...

INPUT:
Holidays
Number Of Days
Start Day
-Extra-: Including Saturdays. (Workday works only from Monday To
Friday)

*OUTPUT:*
Deadline Day


--
Chuy
------------------------------------------------------------------------
Chuy's Profile: http://www.excelforum.com/member.php...o&userid=30603
View this thread: http://www.excelforum.com/showthread...hreadid=502589


vezerid

Workday - Saturdays Included - Holidays Excluded
 
I resorted to VBA. The following UDF should work. I tested it a bit,
but maybe it requires more testing. If you spot any errors post it in
the .programming group, since I have to go.

Function SatWorkday(StartDay As Date, Duration As Integer, Holidays As
Range) As Date
Dim MyDay As Date
Dim i As Integer
i = 1
MyDay = StartDay
While i <= Duration
MyDay = MyDay + 1
sun = (Application.WorksheetFunction.Weekday(MyDay, 1) = 1)
'hol = Not IsError(Application.WorksheetFunction.Match(MyDay,
Holidays, 0))
s = "isnumber(match(" & CLng(MyDay) & "," & Holidays.Address &
",0))"
hol = Evaluate(s)
If Not sun And Not hol Then i = i + 1
Wend
SatWorkday = MyDay
End Function

This should work as in =SatWorkDay(E1, E2, H1:H3), where E1 is the
starting date, E2 the no of days and H1:H3 the holidays. To use it:

Alt+F11 for the VBA IDE
Insert | Module
Paste the code

HTH
Kostis Vezerides

(still eager to see if someone will come up with a formula-based
solution)



All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com