Function networkingdays(sDate As Date, eDate As Date, workingDays As String) As Integer
' This function tells you how many working days are there between 2 given dates.
' You can use this to calculate working days in countries where saturday and sunday are
' not usually holidays
' eg. use: =networkingdays("01-06-2009","02-07-2019","12356")
' will tell you the count of mondays, tuesdays, wednesdays, fridays and saturdays
' between 01-06-2009 and 02-07-2019
Dim totalDays, startDay As Integer
Dim curWeekday As Integer
Dim i, retVal As Integer
totalDays = eDate - sDate + 1
startDay = Weekday(sDate, vbMonday)
retVal = 0
For i = 1 To 7
curWeekday = (startDay - i) Mod 7 + 1
If InStr(workingDays, CStr(i)) > 0 Then
retVal = retVal + Int(totalDays / 7)
If curWeekday <= totalDays Mod 7 Then
retVal = retVal + 1
End If
End If
Next i
networkingdays = retVal
End Function