View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Colin Hayes Colin Hayes is offline
external usenet poster
 
Posts: 465
Default Match and delete rows on two different sheets from reference numbers

In article , Claus Busch
writes
Sub DeleteRows()
Dim LRow As Long
Dim LRow2 As Long
Dim i As Long

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 Sub


Hi Claus

OK this works perfectly - thank you.

BTW I see that altering 0 to 1 in the line

If WorksheetFunction.CountIf(Sheets("Sheet2") _
Range("A1:A" & LRow2), .Cells(i, 1)) = 0 Then.Rows(i).Delete

gives the reverse function.

Would it be possible to build in a popup message box so the user can
enter 0 or 1 to get the action required?



Best Wishes