slimjen,
Here is a function to get working days between 2 dates.
Code:
'---------------------------------------------------------------------------------------
' Procedure : fWorkingDays
' Author : --adapted from Bytes by A Dezii
' Date : 16/7/2015
' Purpose : to get weekdays/business days between 2 dates.
'
' A simple Function to count the number of Workdays between 2 dates,
'Result does not include Saturdays, Sundays nor Federal/Stat Holidays.
'Create a Table named tHolidays with a single DATE/TIME Field named [HolidayDate].
'Populate this Table with any/all work related Holidays.
'
'Inputs: StartDate, and EndDate
'Returns: an Integer representing the number of Workdays/Business
'---------------------------------------------------------------------------------------
'
Public Function fWorkingDays(dteStartDate As Date, dteEndDate As Date) As Integer
Dim intCount As Integer
10 On Error GoTo fWorkingDays_Error
20 intCount = 0
30 Do While dteStartDate <= dteEndDate
40 Select Case WeekDay(dteStartDate) 'what is the weekday(1=Sun....7=Sat)
Case Is = 1 Or 7 'If it's a Saturday or Sunday, do nothing
50 Case Is = 2, 3, 4, 5, 6 'A weekday but
' is it a Holiday as posted in tblHolidays?
60 If DCount("*", "tHoliday", "HolidayDate = #" & dteStartDate & "#") < 1 Then 'NOT Holiday
70 intCount = intCount + 1 ' so increment if weekday and not a holiday
80 End If
90 End Select
100 dteStartDate = dteStartDate + 1
110 Loop
120 fWorkingDays = intCount
130 On Error GoTo 0
140 Exit Function
fWorkingDays_Error:
150 MsgBox "Error " & Err.Number & " in line " & Erl & " (" & Err.Description & ") in procedure fWorkingDays."
End Function