Verify data in two sheets

XLant

New Member
Joined
May 21, 2011
Messages
1
Verify data from sheet2 columns L, N, and O, with data on sheet1 columns L, N, and O, and if they are equal then cut the record from sheet 1 and paste it to the last empty row on sheet 2. I am using Excel 2010, and my OS is Vista. I am very new to Excel coding so it would be much appreciated if you could put lots of comments in the code so to help me understand it.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I'm not sure if this is what you want. It is looking for an exact match on the same row

Code:
Sub cpare()
Dim LR As Long, i As Long, r As Range
With Sheets("Sheet1")
    LR = .Range("L" & Rows.Count).End(xlUp).Row
    For i = 1 To LR
        With .Range("L" & i)
            If .Value = Sheets("Sheet2").Range("L" & i).Value And .Offset(, 2).Value = Sheets("Sheet2").Range("N" & i).Value And .Offset(, 3).Value = Sheets("Sheet2").Range("O" & i).Value Then
                If r Is Nothing Then
                    Set r = .EntireRow
                Else
                    Set r = Union(r, .EntireRow)
                End If
            End If
        End With
    Next i
End With
If Not r Is Nothing Then r.Copy Destination:=Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1)
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top