Search code examples
excelgoogle-sheetslibreoffice

VLOOKUP search by Email Address Not Working in LibreOffice or Google Sheets


My First Sheet

Customer_Email

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

On 2nd Sheet

ID      Customer_Email

1058 [email protected]
771 [email protected]
601 [email protected]
619 [email protected]
459 [email protected]
418 [email protected]
590 [email protected]
557 [email protected]
226 [email protected]
702 [email protected]
21  [email protected]
362 [email protected]
1005    [email protected]
167 [email protected]
966 [email protected]
560 [email protected]

I need the corresponding ID from sheet2 to sheet1

The below one I used in sheet1's B2 Cell

=VLOOKUP(A2,Sheet2!A$2:B$1000,1,0)

Returns N/A and the error shows Did not find value '[email protected]' in VLOOKUP evaluation.


Solution

  • According to the VLOOKUP syntax - the search for values takes place in the first column of the range. In your formula VLOOKUP tries to find the value '[email protected]' in the column Sheet2!A$2:A1000 and clearly can not find it there, because this text is in the range Sheet2!B$2:B1000

    In Google Sheets you can use the following formula =ARRAYFORMULA(VLOOKUP(A2,{Sheet2!B:B,Sheet2!A:A},2,0)) - here we swap the ranges for finding the key and the range for output directly in the formula