I have two sheets, the array macro below detects the last row, then indexes column D, then matches data from column A on Sheet1 to column A on Sheet2 and matches column B on sheet 1 to column E on Sheet2. Then it returns the corresponding value from the indexed column to column G on Sheet1 if the value exists. The macro works fine however I am not advanced enough to make it work faster. Sheet2 contains over 270K rows to search through and it takes quite a long time with 50k rows on Sheet1. Is there a way to make this loop through the records to speed up the process? or in general make the returns faster?
Sub Macro4()
Range("G2").Select
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Selection.FormulaArray = _
"=INDEX(Sheet2!R8C4:R280007C4, MATCH(1,(RC[-6]=Sheet2!R8C1:R280007C1)*(RC[-5]=Sheet2!R8C5:R280007C5),0))"
Selection.AutoFill Destination:=Range("G2:G" & Lastrow), Type:=xlFillDefault
Range("G2:G280007").Select
End Sub
Bookmarks