Hello. I am using the below code courtesy of The Smiley Coder which works beautifully. I would now like to carve out holidays in addition to the weekends. I believe I will have to create a table of the holidays, but I'm not certain how to work it into the code. Any assistance is greatly appreciated.
Public Function addWorkDays(Dat eInput As Date, intDays As Integer) As Date
'Function that only adds days if they are workdays (monday-friday)
'Holidays are not excluded.
'Setup a working date
Dim myDT As Date
myDT = DateInput
'Setup number of days remaining to add
Dim intDaysRemain As Integer
intDaysRemain = intDays
'Now add days 1 at a time,
' while counting down intDaysRemain,
' but only if day is a working day
Do Until intDaysRemain = 0
myDT = DateAdd("d", 1, myDT)
Select Case Weekday(myDT)
Case vbMonday, vbTuesday, vbWednesday, vbThursday, vbFriday
intDaysRemain = intDaysRemain - 1
Case vbSaturday, vbSunday
'Don't modify intDaysRemain
End Select
Loop
'Return answer
addWorkDays = myDT
End Function
Public Function addWorkDays(Dat eInput As Date, intDays As Integer) As Date
'Function that only adds days if they are workdays (monday-friday)
'Holidays are not excluded.
'Setup a working date
Dim myDT As Date
myDT = DateInput
'Setup number of days remaining to add
Dim intDaysRemain As Integer
intDaysRemain = intDays
'Now add days 1 at a time,
' while counting down intDaysRemain,
' but only if day is a working day
Do Until intDaysRemain = 0
myDT = DateAdd("d", 1, myDT)
Select Case Weekday(myDT)
Case vbMonday, vbTuesday, vbWednesday, vbThursday, vbFriday
intDaysRemain = intDaysRemain - 1
Case vbSaturday, vbSunday
'Don't modify intDaysRemain
End Select
Loop
'Return answer
addWorkDays = myDT
End Function
Comment