AlvaroSiza,
This is how I would do it. It only uses a single array, and uses the .Find method to look for matches and then loads it into the array. It outputs the array at the end:
Sub DoItArray()
Dim CalcMode As Long
Dim rngFound As Range
Dim rngList As Range
Dim arrList As Variant
Dim i As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.EnableEvents = False
.ScreenUpdating = False
End With
'This is the range in Sheet1!A:B
'We are going to look for matches in Sheet2!A:A for each cell in Sheet1!A:A
'We are getting the B column so that it is included in the array, as column B will contain the results
Set rngList = Intersect(Sheets("Sheet1").UsedRange, Sheets("Sheet1").Range("A:B"))
arrList = rngList.Value2
For i = 1 To UBound(arrList, 1)
'Perform a .Find for the column A item in the array
Set rngFound = Sheets("Sheet2").Columns("A").Find(arrList(i, 1), , , xlWhole)
If Not rngFound Is Nothing Then
'Found a match, load the result into column B in the array
arrList(i, 2) = rngFound.Offset(, 1).Value2
Set rngFound = Nothing
End If
Next i
'Output results
rngList.Value = arrList
With Application
.Calculation = CalcMode
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Bookmarks