title: Delete rows based on cell color excel vba
body: <p>I am trying to delete rows based on cell color. The issue I run into is the code I wrote keeps "skipping rows":</p>
  
  <pre><code> For i = 2 To lastRow
  'MsgBox (Cells(i, 1) &amp; " " &amp; Cells(i, 1).Interior.ColorIndex)
      If Worksheets("Export Worksheet").Cells(i, 1).Interior.ColorIndex &lt;&gt; "4" Then
         'MsgBox ("Row " &amp; i &amp; " will be deleted")
         Rows(i).EntireRow.Delete
         'MsgBox ("i is currently " &amp; i)
         i = i + 1
      'MsgBox ("i is now " &amp; i)
      End If
  
  Next i
  </code></pre>
  
  <p>Can someone help? Thanks!!</p>