Compare colomns in to Sheets and Paste Difference

Plukey

New Member
Joined
Apr 19, 2019
Messages
32
I'm using a current code to paste differences results it works perfect, but it only paste single column of non matches ...But, I need it to paste entire row. In reality Id like it to compare two columns G & H separately if possible, in both sheets, right now, ive just added the two together in a helper column..
Code:
Sub FindDifferences()
    Dim i As Long, ii As Long, sq1 As Variant, sq2 As Variant, m As Long

    sq1 = Sheet2.Cells(1).CurrentRegion.Columns(1)
    sq2 = Sheet14.Cells(1).CurrentRegion.Columns(1)

    Sheet3.Columns(1).ClearContents

    For i = 1 To UBound(sq1)
        ii = 0
        On Error Resume Next
        ii = Application.Match(sq1(i, 1), sq2, 0)
        On Error GoTo 0
        If ii = 0 Then
            m = m + 1
            Sheet3.Cells(m, 1).Value = sq1(i, 1)
        End If
    Next

    For i = 1 To UBound(sq2)
        ii = 0
        On Error Resume Next
        ii = Application.Match(sq2(i, 1), sq1, 0)
        On Error GoTo 0
        If ii = 0 Then
            m = m + 1
            Sheet3.Cells(m, 1).Value = sq2(i, 1)
        End If
    Next

End Sub
 
Last edited:

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Watch MrExcel Video

Forum statistics

Threads
1,096,444
Messages
5,450,485
Members
405,613
Latest member
Arpit

This Week's Hot Topics

Top