Good evening to all.
This code was provide by Tek-Tips "TheAceman1" save me a lot of time and grief.
Could I ask if someone could help me modify this code to calculate the number of working days in a given month. For example this month "March" has 24.5 working days, We count sat as a half a day. The code below give you the amount of days that are left in a month. Any help is greatly appreciated.
Code:
Function Work_Days(BegDate As Variant, endDate As Variant) As Single
' Note that this function does not account for holidays.
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Single
BegDate = DateValue(BegDate)
endDate = DateValue(endDate)
WholeWeeks = DateDiff("w", BegDate, endDate)
DateCnt = DateAdd("ww", WholeWeeks, BegDate)
EndDays = 0
Do While DateCnt < endDate
If Format(DateCnt, "ddd") = "Sat" Then
EndDays = EndDays + 0.5
ElseIf Format(DateCnt, "ddd") <> "Sun" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = WholeWeeks * 5.5 + EndDays
End Function
Testkitt2