A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
make a copy before you run the code..
i assume that data on both sheets are in column A.
(in row 1 are headings)
try this...
Sub DeleteNotMatch()
Const sh1Col As String = "A" ' << sheet1 data in col A, change
Const sh2Col As String = "A" ' << sheet2 data in col A, change
Dim ws1 As Worksheet, ws2 As Worksheet
Dim r1 As Long, r2 As Long
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
r1 = ws1.Cells(Rows.Count, sh1Col).End(xlUp).Row
r2 = ws2.Cells(Rows.Count, sh2Col).End(xlUp).Row
For i = r1 To 2 Step -1
For Each r In ws2.Range(sh2Col & "2:" & sh2Col & r2)
If ws1.Cells(i, sh1Col).Value = r.Value Then GoTo myNext
Next r
ws1.Cells(i, sh1Col).EntireRow.Delete
myNext:
Next i
End Sub