Vlook Macro for comparing 2 sheet 3 column

sock

New Member
Joined
Mar 28, 2012
Messages
32
Creating a validation sheet with comparing two sheets & Columns.

Result should be "Match" or "Miss Match"

Sheet1 "A" = Sheet2 "A" Result in Sheet2 "D".
Sheet1 "B" = Sheet2 "B" Result in Sheet2 "E"
Sheet1 "C" = Sheet2 "C" Result in Sheet2 "F"

Rows may vary between 2 sheets.

I did the below code but its not working if we have duplicate line in sheet 2.

Code:
Sub test()
Dim LA As Long
Dim LB As Long
Dim LC As Long

LA = Sheet2.Range("A999999").End(xlUp).Row
For i = 1 To LA
    If Sheet1.Range("A" & i).Value = Sheet2.Range("A" & i).Value Then
        Sheet2.Range("D" & i).Value = "Yes"
    Else
        Sheet2.Range("D" & i).Value = "No"
    End If
    
LB = Sheet2.Range("A999999").End(xlUp).Row
'For i = 1 To LB
    If Sheet1.Range("B" & i).Value = Sheet2.Range("B" & i).Value Then
        Sheet2.Range("E" & i).Value = "Yes"
    Else
        Sheet2.Range("E" & i).Value = "No"
    End If
    
LC = Sheet2.Range("A999999").End(xlUp).Row
'For i = 1 To LC
    If Sheet1.Range("C" & i).Value = Sheet2.Range("C" & i).Value Then
        Sheet2.Range("F" & i).Value = "Yes"
    Else
        Sheet2.Range("F" & i).Value = "No"
    End If
    
    
    Next
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,225,754
Messages
6,186,825
Members
453,377
Latest member
JoyousOne

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