title: Rewriting VBA For loop more efficiently and faster
body: <p>I have written the following program below which takes in a start date and an end date from the user within cells 2D &amp; 2E. The program will iterated through the rows backwards, deleting the rows where the criteria is not being met. How else could I guide my code to be more efficient and operate faster overall? Any rule of thumbs to speed things up? It currently will process 1164 items within 45 seconds on my machine. </p>
  
  <pre><code>Sub SpecialDates()
  
  Dim n As Long, i As Long, j As Long, date1 As Date, date2 As Date, date3 As Long, startDate As Date, endDate As Date
  
  n = Cells(Rows.Count, "A").End(xlUp).Row
  j = 4
  
  For i = n To 4 Step -1
      j = j + 1
      startDate = Cells(2, "D").Value
      endDate = Cells(2, "E").Value
  
      If Not IsEmpty(Cells(i, "AB").Value) And Not IsEmpty(Cells(i, "AE").Value) Then
          If Cells(i, "AE").Value &gt;= startDate And Cells(i, "AE").Value &lt;= endDate Then
              date1 = Cells(i, "AB").Value 'AB=Entry Date
              date2 = Cells(i, "AE").Value 'AE=Rec'd 'PRIMARY CHECKING DATE'
              date3 = Work_Days(date2, date1)
              If date3 &gt;= 0 Then
                  Cells(i, "BG").Value = date3
              Else
                  Rows(i).EntireRow.Delete
              End If
          Else
              Rows(i).EntireRow.Delete
          End If
      Else
          Rows(i).EntireRow.Delete
      End If
  Next i
  
  End Sub
  </code></pre>