<-- Previous || Up || Next -->

Number Work Days Test Sub
Dates Times Class

Public Sub NumberWorkDaysTest()
    'Compare the NumberWorkDays function to Excel's NETWORKDAYS function.

    'Note: You must establish a Reference to atpvbaen.xls within Excel for this to work.

    Const datBeg = #1/1/1991#
    Const datEnd = #1/1/1995#

    Dim Holidays, datStart As Date, intOff%, varResES, varResXL

    Holidays = Array(#1/1/1991#, #2/15/1991#, #3/23/1991#, #4/15/1991#, #5/31/1991#, #7/4/1991#, #9/5/1991#, #11/23/1991#, #12/25/1991#, #1/1/1992#, #2/15/1992#, #3/23/1992#, #4/15/1992#, #5/31/1992#, #7/4/1992#, #9/5/1992#, #11/23/1992#, #12/25/1992#, #1/1/1993#, #2/15/1993#, #3/23/1993#, #4/15/1993#, #5/31/1993#, #7/4/1993#, #9/5/1993#, #11/23/1993#, #12/25/1993#, #1/1/1991#, #2/15/1991#, #3/23/1991#, #4/15/1991#, #5/31/1991#, #7/4/1991#, #9/5/1991#, #11/23/1991#, #12/25/1991#)

    Dim datFm As Date, datTo As Date, intMethod%, lngXL&, lngES&

    For datFm = datBeg To datEnd
        DoEvents
        If Day(datFm) = 5 Then datFm = datFm + 20
        If Day(datFm) = 1 Then Debug.Print Now, datFm

        For datTo = datBeg To datEnd
            If Day(datTo) = 5 Then datTo = datTo + 20

            lngXL = NETWORKDAYS(datFm, datTo, Holidays)
            lngES = NumberWorkDays(datFm, datTo, Holidays)

            If lngXL <> lngES Then
                Debug.Print datFm, datTo, lngXL, lngES, lngES - lngXL
            End If
        Next datTo
    Next datFm

End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.