title: Delete rows based on values not found in another sheet
body: <p>I am trying to does the following:</p>
  <ol>
  <li><p>Compare the value (a string of characters) that is stored in column B of worksheet &quot;State = Closed&quot;, to all the values in column A of another worksheet called &quot;Match List&quot;.</p>
  </li>
  <li><p>Delete any row in the &quot;State = Closed&quot; that does not have a match to the corresponding &quot;Match List&quot; value.</p>
  </li>
  <li><p>The code needs to work with any length (as the number of rows will change) list in &quot;Match List&quot;, as well as any length &quot;State = Closed&quot; worksheet.</p>
  </li>
  </ol>
  <pre class="lang-vb prettyprint-override"><code>Sub ListRemove()
      Application.ScreenUpdating = False
      Dim i As Integer
      Dim b As Integer
      Dim Lastrow As Long
      Dim Lastrowb As Long
      Dim Del As Variant
      Worksheets(&quot;Match List&quot;).Activate
      Set Del = Range(&quot;A1:A67&quot;) '&lt;--- This needs to be modified to work with any length Match List
      Lastrowb = Worksheets(&quot;State = Closed&quot;).Cells(Rows.Count, &quot;A&quot;).End(xlUp).Row
      Lastrow = Cells(Rows.Count, &quot;A&quot;).End(xlUp).Row
  
      For i = 1 To Lastrow
          For b = 1 To Lastrowb
              If Worksheets(&quot;State = Closed&quot;).Cells(i, 2).Value &lt;&gt; Del(b) Then
                  Worksheets(&quot;State = Closed&quot;).Rows(i).EntireRow.Delete
              End If
          Next
      Next
  
      Application.ScreenUpdating = True
      Worksheets(&quot;State = Closed&quot;).Activate
  End Sub
  </code></pre>
  <p>This deletes every row in the &quot;State = Closed&quot; worksheet instead of just the rows that do not contain a corresponding value in the Match List worksheet.</p>