Hi Folks,
Still fairly new to VBA, I am currently using the below code to compare Column A between Sheet1 and Sheet2 then bring in the value of Column B in Sheet2 into Column B of Sheet1.
This is great when working with low row numbers, however, I'm now working on a file with 10000+ rows and the macro is taking very long to process.
Current code;
Would anyone have a more efficient way of doing this to speed up the processing time?Code:Option Explicit
Sub GetValues()
Application.ScreenUpdating = False
Dim i As Long, j As Long
Sheet1LastRow = Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
Sheet2LastRow = Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
For j = 1 To Sheet1LastRow
For i = 1 To Sheet2LastRow
If Worksheets("Sheet1").Cells(j, 1).Value = Worksheets("Sheet1").Cells(i, 1).Value Then
Worksheets("Sheet1").Cells(j, 2).Value = wb.Worksheets("Sheet1").Cells(i, 2).Value
End If
Next i
Next j
End Sub
Many Thanks
Fra