title: Deleting rows based on a condition, and the condition is an array
body: <p>I have 2 columns and 300k rows</p>
  
  <pre><code>F1  21
  F2  32
  F3  43
  F4  4565
  F5  76
  F6  76
  F7  5
  F8  4
  F9  4332
  …   …
  </code></pre>
  
  <p>The first column has 300 different values, and I want to delete all rows which contain specific values. Currently I have;</p>
  
  <pre><code>Sub DeleteRowsBasedOnCondition()
  N = Cells(Rows.Count, 1).End(xlUp).Row
  For i = N To 1 Step -1
      If Cells(i, 1).Value = "F1" Then Rows(i).Delete
  Next i
  End Sub
  </code></pre>
  
  <p>and it removes a single conndition (F1), but this will take a long time to delete 56 conditions.</p>
  
  <p>I have a named list, toRemove, which contains all the fields I want to remove. ie (F1, F2, F4, F9). I would like to refer to this named list instead of running the code 56 times.</p>
  
  <p>I would like</p>
  
  <pre><code>Sub DeleteRowsBasedOnCondition()
  N = Cells(Rows.Count, 1).End(xlUp).Row
  For i = N To 1 Step -1
      If Cells(i, 1).Value has a value in the array toRemove
      Then Rows(i).Delete
  Next i
  End Sub
  </code></pre>
  
  <p>I tried <a href="https://stackoverflow.com/questions/10951687/how-to-search-for-string-in-an-array/10952705#10952705">How to search for string in an array</a> post, but get the following error when referring to the line</p>
  
  <pre><code>function Filter(arr, stringToBeFound):
  Run-Time error '13':
  
  Type mismatch
  </code></pre>
  
  <p>Here is the code I tried:</p>
  
  <pre><code>Sub DeleteRowsBasedOnArrayCondition()
  ' toremove is a named list of values which are to be compared with and deleted from table
  N = Cells(Rows.Count, 1).End(xlUp).Row
  For i = N To 1 Step -1
      If IsInArray(Cells(i, 2).Value, toremove) Then Rows(i).Delete
  Next i
  End Sub
  
  Function IsInArray(stringToBeFound As String, arr As Variant) As Boolean
    IsInArray = (UBound(Filter(arr, stringToBeFound)) &gt; -1)
  End Function
  </code></pre>