Find the same value in column A in different sheet, then paste value in column B, but too long to process

borntobe

Board Regular
Joined
Dec 13, 2013
Messages
66
Hi,
I have 80,000 records in sheet1, and 10,000 records in sheet2.
What I want to do is that I have to find the same value in column A in sheet1 with column A in sheet2.
If I find the same value in column A in sheet1, then copy value in column A and column B in sheet2, then paste it into column D and E in sheet1.

sheet1 looks like below
ABCDE
1
2ItemRate
370.023
480.0115
5200.005
6270.89

<tbody>
</tbody>

sheet2 looks like below
AB
1
2ItemRate
360.12
480.568
5270.047
6330.56

<tbody>
</tbody>

Expect results looks like below
ABCDE
1
2ItemRateItem from sheet2Rate from sheet2
370.023
480.011580.568
5200.005
6270.89270.047

<tbody>
</tbody>

So, I tried below vba code, but it took forever.


Code:
Set wsD = ThisWorkbook.Sheets("sheet1")
lrR = wsD.Cells(Rows.Count, 1).End(xlUp).Row   'col A


Set ws = ThisWorkbook.Sheets("sheet2")  
lr = ws.Cells(Rows.Count, 1).End(xlUp).Row


With ws
    For m = 3 To lr        
                With wsD.Range("A3:A" & lrR)
                    For n =3 To lrR
                        If ws.Range("A" & m) = wsD.Range("A" & n) Then
                           ws.Range("A" & m & ":" & "B" & m).Copy
                      
                           wsD.Range("D" & n).PasteSpecial xlPasteValuesAndNumberFormats
                            GoTo skip
                            
                        End If
                    Next n
                End With
      
skip: 
    Next m
End With

Please advise me how to process this faster and easier way.
Thanks in advance.
 
Last edited:
Fluff

It worked beautifully.
It took around 40 seconds to process about 60,000 rows.
Thanks a lot!
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,216,111
Messages
6,128,899
Members
449,477
Latest member
panjongshing

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