Match and delete rows on two different sheets from reference numbers
Is that what you want?
Sub DeleteRows()
Dim LRow As Long
Dim LRow2 As Long
Dim i As Long
Dim ans As Integer
ans = MsgBox("Do you really want to delete the rows", _
vbOKCancel + vbInformation, "Safety check")
If ans = vbOK Then
LRow2 = Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
With Sheets("Sheet1")
LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For i = LRow To 1 Step -1
If WorksheetFunction.CountIf(Sheets("Sheet2") _
.Range("A1:A" & LRow2), .Cells(i, 1)) = 0 Then
.Rows(i).Delete
End If
Next
End With
End If
End Sub
Regards
Claus B.
Hi Claus
Yes , that's fine. Thanks very much for your help,
Best Wishes
|