First, let's get a list of the values ββthat exist in both tables. If you are using excel 2010 or later, in Sheet 3 A2, enter the following formula:
=IFERROR(AGGREGATE(15,6,Sheet2!$A$1:$A$5000/(COUNTIF(Sheet1!$A$1:$A$5000,Sheet2!$A$1:$A$5000)>0),ROW(1:1)),"")
If you are using 2007 or earlier, use this array formula:
=IFERROR(SMALL(IF(COUNTIF(Sheet1!$A$1:$A$5000,Sheet2!$A$1:$A$5000),Sheet2!$A$1:$A$5000),ROW(1:1)),"")
As an array formula, copy and paste into the formula bar, then press Ctrl-Shift-Enter instead of Enter or Tab to exit edit mode.
Then copy as many lines as you want. This will create an ID'd list that is in both lists. This assumes the identifier is a number, not text.
Then with this list we use vlookup:
=IF(A2<>"",VLOOKUP(A2,Sheet1!A:B,2,FALSE),"")
Then, the value from Sheet 1 that matches is returned.
