Hello,
I'm trying to write a module that excludes weekdays and holidays from a date calculation....this is what I have for the weekdays and was wondering if something could be added to it for the holidays....
Function workdays(Begdate As Variant, enddate As Variant) As Integer
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
Begdate = DateValue(Begdate)
enddate = DateValue(enddate)
WholeWeeks = DateDiff("w", Begdate, enddate)
DateCnt = DateAdd("ww", WholeWeeks, Begdate)
EndDays = 0
Do While DateCnt < enddate
If Format(DateCnt, "ddd") <> "Sun" And Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
workdays = WholeWeeks * 5 + EndDays
End Function
I'm trying to write a module that excludes weekdays and holidays from a date calculation....this is what I have for the weekdays and was wondering if something could be added to it for the holidays....
Function workdays(Begdate As Variant, enddate As Variant) As Integer
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
Begdate = DateValue(Begdate)
enddate = DateValue(enddate)
WholeWeeks = DateDiff("w", Begdate, enddate)
DateCnt = DateAdd("ww", WholeWeeks, Begdate)
EndDays = 0
Do While DateCnt < enddate
If Format(DateCnt, "ddd") <> "Sun" And Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
workdays = WholeWeeks * 5 + EndDays
End Function