So in A1:Axx there are search items.
Let's assume that reference table is in C:D columns and output shall go to B column.
Try the (easy to read but highly not-optimized) code:
Sub test()
Dim outrow As Long, i As Long, j As Long, ID As Variant, referencerow As Long
For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
referencerow = WorksheetFunction.Match(Cells(i, "A"), Columns("D"), 0)
ID = Cells(referencerow, "C")
For j = 1 To Cells(Rows.Count, "C").End(xlUp).Row
If Cells(j, "C").Value = ID Then
outrow = outrow + 1
Cells(outrow, "B").Value = Cells(j, "D").Value
End If
Next j
Next i
End Sub
Bookmarks