I have a text box that contains the "Book Date" and another text box that contains the "Run Date". I want a 3rd. text box to calculate the workdays between the "Book Date" and the "Run Date". I have created a function that should calculate the workdays but I don't know where to place the function so that the function places the number of workdays in the 3rd text box. This is the function that I want to call:
********************************************
Function Work_Days(BookDate As Variant, RunDate As Variant) As Integer
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
BookDate = DateValue(BookDate)
RunDate = DateValue(RunDate)
WholeWeeks = DateDiff("w", BookDate, RunDate)
DateCnt = DateAdd("ww", WholeWeeks, BookDate)
EndDays = 0
Do While DateCnt < RunDate
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = WholeWeeks * 5 + EndDays
End Function
*******************************************
I thank you in advance for your help.
John J. Boyle
********************************************
Function Work_Days(BookDate As Variant, RunDate As Variant) As Integer
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
BookDate = DateValue(BookDate)
RunDate = DateValue(RunDate)
WholeWeeks = DateDiff("w", BookDate, RunDate)
DateCnt = DateAdd("ww", WholeWeeks, BookDate)
EndDays = 0
Do While DateCnt < RunDate
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = WholeWeeks * 5 + EndDays
End Function
*******************************************
I thank you in advance for your help.
John J. Boyle