The following is a simplified function which adds or subtracts workdays:
Public Function WorkDaysAdd(dtmDateFrom As Date, intDays As Integer) As Date
Dim dtmDate As Date
Dim n As Integer
Dim intIncr As Integer
' value by which date will be incremented
' each day is 1 or -1 depending on sign of
' intDays argument
intIncr = intDays / Abs(intDays)
' initialize date from which to count
dtmDate = dtmDateFrom
' add days one by one
For n = 1 To Abs(intDays)
dtmDate = DateAdd("d", intIncr, dtmDate)
' skip weekends
Do While Weekday(dtmDate, vbMonday) > 5
dtmDate = DateAdd("d", intIncr, dtmDate)
Loop
Next n
WorkDaysAdd = dtmDate
End Function
To return the date two working days before today call it like so:
WorkDaysAdd(Date(),-2)
This simplified function does not take account of public holidays, however,
but its quite a simple task to build that in so that the code looks up rows
in a Holidays table and discounts them.
Ken Sheridan
Stafford, England