[FONT=Times New Roman][SIZE=3]Function Work_Days(BegDate As Variant, EndDate As Variant) As Integer[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] Dim WholeWeeks As Variant[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Dim DateCnt As Variant[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Dim EndDays As Integer[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] On Error GoTo Err_Work_Days[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] BegDate = DateValue(BegDate)[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] EndDate = DateValue(EndDate)[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] WholeWeeks = DateDiff("w", BegDate, EndDate)[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] DateCnt = DateAdd("ww", WholeWeeks, BegDate)[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] EndDays = 0[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Do While DateCnt <= EndDate[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] If Format(DateCnt, "ddd") <> "Sun" And _[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Format(DateCnt, "ddd") <> "Sat" Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] EndDays = EndDays + 1[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] End If[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] DateCnt = DateAdd("d", 1, DateCnt)[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Loop[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Work_Days = WholeWeeks * 5 + EndDays[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]Exit Function[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] Err_Work_Days:[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] ' If either BegDate or EndDate is Null, return a zero[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] ' to indicate that no workdays passed between the two dates.[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] If Err.Number = 94 Then[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Work_Days = 0[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Exit Function[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] Else[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]' If some other error occurs, provide a message.[/SIZE][/FONT]
[SIZE=3][FONT=Times New Roman] MsgBox "Error " & Err.Number & ": " & Err.Description[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman] End If[/FONT][/SIZE]
[FONT=Times New Roman][SIZE=3]End Function[/SIZE][/FONT]