Function LastBusDay(D As Variant) As Variant
' Returns the date of the last business day (Mon - Fri) in a month
Dim D2 As Variant
If VarType(D) <> 7 Then
LastBusDay = Null
Else
D2 = DateSerial(Year(D), Month(D) + 1, 0)
Do While WeekDay(D2) = 1 Or WeekDay(D2) = 7
D2 = D2 - 1
Loop
LastBusDay = D2
End If
End Function
Function FirstBusDay(D As Variant) As Variant
' Returns the date of the first business day (Mon - Fri) in a month
Dim D2 As Variant
If VarType(D) <> 7 Then
FirstBusDay = Null
Else
D2 = DateSerial(Year(D), Month(D), 0) + 1
Do While WeekDay(D2) = 1 Or WeekDay(D2) = 7
D2 = D2 + 1
Loop
FirstBusDay = D2
End If
End Function