I have two Sheets Sht1 and Sht2.
I am comparing the column A of sheet1 with column A of sheet2. The column A of both the Sheets, contains ID.
If there is a non matching ID in sheet2, then I want to copy the unmatched row in sheet1.
I tried a code below, and the problem is, it is just copying the unmatched last row of sheet2 multiple times and keeps running without Exit.
Could anyone help me how i could correct it.
Sub trialtest()
Dim srcLastRow As Long, destLastRow As Long
Dim srcWS As Worksheet, destWS As Worksheet
Dim i As Long, j As Long
Application.ScreenUpdating = False
Set srcWS = ThisWorkbook.Sheets("S2")
Set destWS = ThisWorkbook.Sheets("S1")
srcLastRow = srcWS.Cells(srcWS.Rows.Count, "A").End(xlUp).Row
destLastRow = destWS.Cells(destWS.Rows.Count, "A").End(xlUp).Row
For i = 5 To destLastRow
For j = 5 To srcLastRow
If destWS.Cells(i, "A").Value <> srcWS.Cells(j, "A").Value Then
destWS.Cells(i, "A") = srcWS.Cells(j, "A")
destWS.Cells(i, "B") = srcWS.Cells(j, "B")
destWS.Cells(i, "C") = srcWS.Cells(j, "C")
destWS.Cells(i, "D") = srcWS.Cells(j, "D")
destWS.Cells(i, "E") = srcWS.Cells(j, "E")
destWS.Cells(i, "F") = srcWS.Cells(j, "F")
destWS.Cells(i, "G") = srcWS.Cells(j, "G")
destWS.Cells(i, "H") = srcWS.Cells(j, "H")
destWS.Cells(i, "I") = srcWS.Cells(j, "I")
destWS.Cells(i, "J") = srcWS.Cells(j, "J")
destWS.Cells(i, "K") = srcWS.Cells(j, "K")
destWS.Cells(i, "L") = srcWS.Cells(j, "L")
destWS.Cells(i, "M") = srcWS.Cells(j, "M")
destWS.Cells(i, "N") = srcWS.Cells(j, "N")
destWS.Cells(i, "O") = srcWS.Cells(j, "O")
destWS.Cells(i, "P") = srcWS.Cells(j, "P")
destWS.Cells(i, "Q") = srcWS.Cells(j, "Q")
destWS.Cells(i, "R") = srcWS.Cells(j, "R")
destWS.Cells(i, "S") = srcWS.Cells(j, "S")
End If
Next j
Next i
Application.ScreenUpdating = True
End Sub