title: Excel VBA For loop with UsedRange Count Error
body: <pre><code>maxRow = ws.UsedRange.EntireRow.Count
  
  For n = 1 To maxRow
  
      Do While Not IsEmpty(ws.Range(&quot;D&quot; &amp; n).Value)
      
      ws.Range(&quot;D&quot; &amp; n &amp; &quot;:&quot; &amp; &quot;E&quot; &amp; n).Delete shift:=xlShiftToLeft
      Rows(n + 1).Insert shift:=xlShiftDown
      maxRow = maxRow + 1
      
      Loop
  
  Next n
  </code></pre>
  <p>I was just wondering why my code always exit when n = 19 (number of original maxRow count). I added maxRow = maxRow +1 because I inserted one row so that it doesn't exit until it is finished.</p>
  <p>What I am trying to do, is to remove the two cells (D&amp;E) and inserting a row underneath until D&amp;E is empty.</p>
  <p>Thanks</p>