View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
JP.F[_2_] JP.F[_2_] is offline
external usenet poster
 
Posts: 3
Default How do I use the WORKDAY() for a 6days working wk excluding ho

Bernie,

Many Thanks for your help,
Have a nice day,

JP.F

"Bernie Deitrick" wrote:

JP.F,

Here's a version that works with the holiday dates entered into a range of
cells, used like

=DateAddSixDayWorkweek(C2,C3,A2:A4)

where A2:A4 has holiday dates- which should be entered in ascending order.

HTH,
Bernie
MS Excel MVP



Function DateAddSixDayWorkweek(ByVal StartDate As Date, _
WorkDays As Long, Holidays As Range) As Date
Dim myC As Range

If Weekday(StartDate) = 1 Then StartDate = StartDate - 1
DateAddSixDayWorkweek = DateAdd("d", 7 * (WorkDays \ 6) + _
(WorkDays Mod 6) - ((WorkDays Mod 6) _
7 - Weekday(StartDate)), StartDate)

For Each myC In Holidays
If myC.Value = StartDate And myC.Value <= DateAddSixDayWorkweek Then
DateAddSixDayWorkweek = DateAddSixDayWorkweek + _
IIf(Weekday(DateAddSixDayWorkweek + 1) = 1, 2, 1)
End If
Next myC

End Function

"JP.F" wrote in message
...
Could someone help me with below code from "Rick Rothstein (MVP - VB)"
where
holidays are excluded .
Many thanks,
JP.F



Function DateAddSixDayWorkweek(ByVal StartDate As Date, _
WorkDays As Long) As Date
If Weekday(StartDate) = 1 Then StartDate = StartDate - 1
DateAddSixDayWorkweek = DateAdd("d", 7 * (WorkDays \ 6) + _
(WorkDays Mod 6) - ((WorkDays Mod 6) _
7 - Weekday(StartDate)), StartDate)
End Function