Public Function fntWorkDays(varStartDate As Variant, varEndDate As Variant) As Long
'Returns the number of actual workdays between two dates and also accounts for holidays
Dim lngCounter As Long
Dim lngDayCount As Long
Dim aryHolidaysList()
Dim aryMember
Dim blnFound As Boolean
blnFound = False
varStartDate = DateValue(varStartDate)
varEndDate = DateValue(varEndDate)
aryHolidaysList = Array("1/1/2012", "1/16/2012", "2/20/2012", "5/28/2012", "7/4/2012", "9/3/20121", "10/8/2012", _
"11/12/2012", "11/22/2012", "12/25/2012")
For lngCounter = varStartDate To varEndDate
If Weekday(lngCounter, vbMonday) < 6 Then
For Each aryMember In aryHolidaysList
If Format(aryMember, "mm/dd/yyyy") = Format(lngCounter, "mm/dd/yyyy") Then
blnFound = True
Exit For
Else
blnFound = False
End If
Next aryMember
If blnFound = False Then
lngDayCount = lngDayCount + 1
End If
End If
Next lngCounter
fntWorkDays = lngDayCount
End Function
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE