I\'ve been looking at using the Excel VLOOKUP function to accomplish this, but I\'m pretty unfamiliar with it.
I need to do the following:
On sheet one, column A
I would suggest a VBA script that uses an SQL query, maybe something like this (you need some SQL language skills in order to get the right result). Anyways, this is the approach I would recommend for an advanced user:
Dim oConn As ADODB.Connection, rs As ADODB.Recordset
sWorkbookName = ThisWorkbook.FullName
connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=""" &
sWorkbookName & """;Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX = 1"""
sSheet1="myDataSheet1"
sSheet2="myDataSheet2"
oConn.Open connString
'just an example of SQL, you have to customize it
sSQL = "SELECT [FIRST NAME], [LAST NAME],[EMAIL] FROM [" & sSheet2 & "$] " &
" WHERE
[FIRST NAME] + [LAST NAME} IN (SELECT [FIRST NAME] + [LAST NAME] FROM [" & sSheet1 & "$]" & ") ORDER BY [FIRST NAME] ASC"
rs.Open sSQL, oConn, adOpenStatic, adLockOptimistic, adCmdText
'dump results on a temporary sheet
ThisWorkbook.Worksheets("tmp_sheet").Range("A2").CopyFromRecordset rs
rs.Close
oConn.Close