Dim sh1 as Worksheet, sh2 as Worksheet
Dim i as Long
set sh2 = Worksheets(2)
set sh1 = Worksheets(1)
lastrow = sh1.Cells(Rows.Count, "A").End(xlUp).Row
For i = lastrow To 1 Step -1
If sh1.Cells(i, "A").Value = sh2.Cells(i, "A").Value Then
sh1.Rows(i).Delete
End If
Next
you can replace the 2 and 1 (refers to tab order) with actual worksheet
names such as Sheet3 and Sheet4 for example.
set sh1 = Worksheets("Sheet3")
--
Regards,
Tom Ogilvy
"mike.wilson8@comcast.net" wrote:
> I currently have this existing code that checks to if the value is the
> same between col E and P and if true, the row is deleted.
>
> 'lastrow = Cells(Rows.Count, 4).End(xlUp).Row
> 'For i = lastrow To 1 Step -1
> ' If Cells(i, "E").Value = Cells(i, "P").Value Then
> ' Rows(i).Delete
> 'End If
> 'Next
>
>
> How can I change this to compare values between col A in worksheet 1
> and col A in worksheet 2, and if the value is the same, delete that row
> in worksheet 1?
>
> Thank you,
> Mike
>
>
Bookmarks