Function ProjectedDate(dteBegDate As Date, lngNumDays As Long, blnSkipWeekEnds As Boolean, blnSkipHolidays As Boolean) As Date
'Get Forward or Backward Date from a Beginning Date
'Count starts with Day after Beginning Date
'If blnSkipWeekEnds or blnSkipHolidays = True, these days are NOT included when counting,
' hence, the projected date is <> then when they are included (= False)
'Usage
' dteNew = ProjectedDate("5/8/2004", 30, False, False)
Dim lngCnt As Long
Dim dblBegDate As Long
'--------------
dblBegDate = CDbl(dteBegDate)
lngCnt = 0
If lngNumDays > 0 Then
Do
'Increment Date (start with next day)
dblBegDate = dblBegDate + 1
'Skip Weekends
If blnSkipWeekEnds Then
If WeekDay(dblBegDate) = vbSunday Then GoTo Skip
If WeekDay(dblBegDate) = vbSaturday Then GoTo Skip
End If
'Holidays (need database/array or lookup table)
If blnSkipHolidays Then
End If
lngCnt = lngCnt + 1
Skip:
Loop Until lngCnt = lngNumDays
Else 'Projected Date is in the Past
lngNumDays = Abs(lngNumDays)
Do
'Increment Date (start with next day)
dblBegDate = dblBegDate - 1
'Skip Weekends in Count
If blnSkipWeekEnds Then
If WeekDay(dblBegDate) = vbSunday Then GoTo Skip1
If WeekDay(dblBegDate) = vbSaturday Then GoTo Skip1
End If
'Holidays (need database/array or lookup table)
If blnSkipHolidays Then
End If
lngCnt = lngCnt + 1
Skip1:
Loop Until lngCnt = lngNumDays
End If
ProjectDate = CDate(dblBegDate)
End Function