title: Remove row if cell value not in list
body: <p>I have 2 sheets : in the first i have date and in sheet2 i have a list of names in column A . I want to delete all the rows that don't have the names from sheet2 in the column O from the first sheet. The code just deletes everything from the first sheet. Any help is welcomed.</p>
  
  <pre><code>Sub Demo()
  Dim Rng As Range, List As Object, Rw As Long
  Dim x As Date
  x = Now()
  
  Set List = CreateObject("Scripting.Dictionary")
  With Sheets("Sheet2")
    For Each Rng In .Range("A1", .Range("A" &amp; Rows.Count).End(xlUp))
      If Not List.Exists(Rng.Value) Then
        List.Add Rng.Value, Nothing
      End If
    Next
  End With
  
  With Sheets("query " &amp; Format(x, "dd.mm.yyyy"))
    For Rw = .Range("O" &amp; Rows.Count).End(xlUp).Row To 1 Step -1
      If Not List.Exists(.Cells(Rw, "O").Value) Then
        .Rows(Rw).Delete
      End If
    Next
  End With
  
  Set List = Nothing
  End Sub
  </code></pre>