PDA

View Full Version : Solved: if find data delete the row on another sheet



parscon
08-14-2012, 02:45 PM
I have a some data on sheet 1 column A and also some data on sheet 2.
Now I need a VBA code if have the same data on sheet 2 delete the row on sheet 2 of that data .

Note : just check with sheet 1 column A .

Thank you very much for your big help .:hi:

mancubus
08-14-2012, 03:30 PM
so you're comparing column A's of Sheet1 & Sheet2, and deleting the matching rows from Sheet2...

if this is the scenario then try :


Sub DelMatchedRows()

Dim LastRow As Long, i As Long, mRow As Long

With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For i = 1 To LastRow
On Error Resume Next
mRow = Application.Match(.Cells(i, 1), Worksheets("Sheet2").Columns(1), 0)
If mRow > 0 Then Worksheets("Sheet2").Rows(mRow).EntireRow.Delete
Next
End With

End Sub

parscon
08-14-2012, 03:41 PM
That’s correct and thank you so much .