title: Delete rows (dynamic amount) based on cell's content
body: <p>Sorry if this is simple, this is my first time trying VBA.</p>
  
  <p>So I want this macro to get rid of rows I don't need, and for every entity it has a total field (about every 20 records or so) and I made this script:</p>
  
  <pre><code>Dim i As Integer
  Dim LastRow As Integer
  LastRow = Range("A65536").End(xlUp).Row
  
  For i = 3 To LastRow
      If Range("C" &amp; i) = "Result" Then
          Rows(i &amp; ":" &amp; i).Select
          Selection.Delete Shift:=x1Up
      End If
  Next
  </code></pre>
  
  <p>And that worked perfectly! Then I tried to a similar thing.. I tried to go through each row (record) in a data set and then if a certain field does not contain the string "INVOICE" then I don't need that row and I can delete it. So I just added into my current loop (why loop twice?) So now it looks like this:</p>
  
  <pre><code>Dim i As Integer
  Dim LastRow As Integer
  LastRow = Range("A65536").End(xlUp).Row
  
  For i = 3 To LastRow
      If Range("C" &amp; i) = "Result" Then
          Rows(i &amp; ":" &amp; i).Select
          Selection.Delete Shift:=x1Up
      End If
      If Not InStr(1, Range("Q" &amp; i), "INVOICE") Then
          Rows(i &amp; ":" &amp; i).Select
          Selection.Delete Shift:=x1Up
      End If
  Next
  </code></pre>
  
  <p>That second bit as far as I can tell just randomly starts deleting rows with no rhyme or reason. Rows where the Q field doesn't contain invoice sometimes stay sometimes go, and same if it does contain invoice. Any idea what I'm doing wrong?</p>