title: I need a VBA function to count the working days between two dates
body: <p>I have this one:</p>
  
  <pre><code>Public Function WorkingDays(StartDate As Date, _
                          ByVal EndDate As Date, _
                          Optional ByVal Holidays As Range, _
                          Optional ByVal Workdays As Variant) As Long
  Dim mpDays As Long
  Dim mpHolidays As Variant
  Dim mpWorkdays As Variant 
  Dim i As Long
  If Not Holidays Is Nothing Then mpHolidays = Application.Transpose(Holidays)
  If IsMissing(Workdays) Then
      mpWorkdays = Array(2, 3, 4, 5, 6)
  Else
      mpWorkdays = Workdays
  End If
  For i = StartDate To EndDate
  
      If Not IsError(Application.Match(Weekday(i), mpWorkdays, 0)) Then
  
          If IsError(Application.Match(i, mpHolidays, 0)) Then
              mpDays = mpDays + 1
          End If
      End If
  Next i
  WorkingDays = mpDays 
  End Function
  </code></pre>
  
  <p>but it is very slow, 
  I use this function in my Workbook and my sheet I've 130K records. How can it be improved?</p>