Oops, I forgot to comment out the second test for Saturday.
How do I have the workday formula include Saturdays?
There is no particular argument to allow that.
This UDF is one way of doing it. Note that the test for Saturday is commented
out. The UDF was written to give a WORKDAY equivalent without using the
Analysis ToolPak, and should work regardless of one's region.
The disadvantage of this approach is that it will run much slower than the
built-in functions. However, if you don't have many instances of the formula,
that should not be an issue.
======================================
Function WD(StartDate As Date, ByVal NumDays As Long, _
Optional Holidays As Range = Nothing) As Date
'Workday function without Analysis Toolpak
Dim i As Long
Dim TempDate As Date
Dim c As Range
Dim Stp As Integer
Stp = Abs(NumDays) / NumDays
TempDate = StartDate
For i = Stp To NumDays Step Stp
TempDate = TempDate + Stp
'If Weekday(TempDate) = vbSaturday Then _
TempDate = TempDate + Stp - (Stp > 0)
If Weekday(TempDate) = vbSunday Then _
TempDate = TempDate + Stp + (Stp < 0)
If Not Holidays Is Nothing Then
Do Until Not IsError(Application.Match(CDbl(TempDate), Holidays, 0)) = False
If IsError(Application.Match(CDbl(TempDate), Holidays, 0)) = False Then
TempDate = TempDate + Stp
'If Weekday(TempDate) = vbSaturday Then _
TempDate = TempDate + Stp - (Stp > 0)
If Weekday(TempDate) = vbSunday Then _
TempDate = TempDate + Stp + (Stp < 0)
End If
Loop
End If
Next i
WD = TempDate
End Function
========================
--ron