XLA routines: EE_BusinessDaysInDateRange

Nick's picture
EE_BusinessDaysInDateRange takes 2 dates, and a holiday calendar, and returns the number of business days in the date range.
Function EE_BusinessDaysInDateRange(dt1 As Date, dt2 As Date, rngHolidays As range)
'Takes date 1, date 2 and works out the amount of business days between them
'- takes range of holidays
    Dim intLoop         As Date
    Dim intDaysCount    As Integer
 
'http://excelexperts.com/xla-routines-eeBusinessDaysInDateRange    for updates on this function

    For intLoop = dt1 To dt2 Step IIf(dt1 > dt2, -1, 1)
        If EE_IsBusinessDay(rngHolidays, intLoop) Then
            intDaysCount = intDaysCount + 1
        End If
    Next intLoop
 
    EE_BusinessDaysInDateRange = intDaysCount
End Function