How to pull data from another table in Excel with XLOOKUP and VLOOKUP
Match records in two tables by a common column: XLOOKUP and VLOOKUP formulas that bring a price from another sheet using a product code, IFERROR for codes that are not found, and which Excel versions have which function.

You may have an order list with product codes on one sheet and a table with the price of each code on another. Instead of copying prices one by one, you can use Excel's lookup functions to match the records by the common column (here, the product code) and bring the value in automatically.
This guide covers XLOOKUP, available in Microsoft 365, Excel 2021 and 2024, VLOOKUP for Excel 2016 and 2019, IFERROR for codes that are not found, and the argument separator, with one concrete example. Function names and syntax were taken from Microsoft's support pages.
- Time10 minutes
- DifficultyMedium
- Steps9
๐งฐ What you need
- Microsoft 365, Excel 2021 or Excel 2024 for XLOOKUP; in Excel 2016 and 2019 you use VLOOKUP
- Two tables that share a common column (for example, both contain a product code); in this guide the tables sit on two worksheets named "Orders" and "Prices"
- The lookup value and the list you search must be the same type (both text or both numbers)
Steps
- Identify the example tables and the common columnThe example: on the "Orders" sheet, product codes run down from A2, the product name will go in column B and the unit price in column C. On the "Prices" sheet, column A is Code, column B is Product Name, column C is Unit Price, and the data runs from row 2 to row 100. The common column is the product code: you have the code on Orders, Excel looks it up on Prices and returns the information next to it.
- Prepare the data for matchingAccording to Microsoft, leading and trailing spaces, inconsistent quotation marks and numbers stored as text can stop a lookup from finding a match. If you suspect invisible spaces in the code columns, use the TRIM or CLEAN function in a helper column. Make sure the codes are not numbers in one table and text in the other.
- Choose the function for your versionXLOOKUP is available in Microsoft 365, Excel 2021 and Excel 2024; according to the Microsoft page it is not available in Excel 2016 and Excel 2019. If your version is older, go to step 7 and use VLOOKUP. Microsoft also notes that you may end up using a workbook that contains XLOOKUP in Excel 2016 or 2019; in that case remember the function does not exist in that version.
- Mind the argument separatorArguments in a formula are separated by the list separator. Microsoft says which separator applies depends on your operating system's regional settings and Excel settings, and that a wrong separator breaks the formula. The formulas in this guide use commas, as Microsoft's function pages do; if your Excel uses semicolons as the list separator (Microsoft's Turkish page says semicolon for Turkish regional settings), type semicolons instead.
- Write the XLOOKUP formulaOn the Orders sheet select B2 and type =XLOOKUP(A2,Prices!$A$2:$A$100,Prices!$B$2:$B$100). In order, these are: the lookup value (the code in A2), the lookup_array (the code column on Prices) and the return_array (the column to bring back). XLOOKUP searches for an exact match by default. To bring back the price, type =XLOOKUP(A2,Prices!$A$2:$A$100,Prices!$C$2:$C$100) in C2. If a sheet name contains a space, put it in single quotes: 'Price List'!$A$2:$A$100.
- Add a message for codes that are not foundThe fourth argument of XLOOKUP is [if_not_found]; if there is no match, that text is shown, and if you leave it out you get a #N/A error. Write C2 like this: =XLOOKUP(A2,Prices!$A$2:$A$100,Prices!$C$2:$C$100,"Code not found"). A code that is not on the list then returns a readable message instead of an error.
- Do the same job with VLOOKUPIf you use Excel 2016 or 2019, type this in C2: =VLOOKUP(A2,Prices!$A$2:$C$100,3,FALSE). In order: lookup_value (A2), table_array (the range on Prices from A to C; the code you are looking for must be in the FIRST column of the range), col_index_num (3, the third column of the range, which is Unit Price) and range_lookup (FALSE, meaning an exact match). If you leave the last argument out, the default is TRUE and VLOOKUP does an approximate match; always write FALSE when you look up codes.
- Catch the error with IFERROR in VLOOKUPVLOOKUP has no separate argument for a message. Wrap the formula in IFERROR: =IFERROR(VLOOKUP(A2,Prices!$A$2:$C$100,3,FALSE),"Code not found"). IFERROR(value, value_if_error) catches not only #N/A but also #VALUE!, #REF!, #NUM!, #NAME? and other errors, so it can hide a different error in your formula as well. If you see errors although the codes exist in both tables, temporarily remove IFERROR and read the real error.
- Fill the formula down and check the resultBecause you wrote the ranges with $ signs (absolute references), the lookup range does not shift when you fill the formula down; Microsoft also recommends absolute references so that the formula always looks at exactly the same lookup range. Select the formula cell and drag the fill handle in the bottom-right corner to the last row. Then check a few rows by hand: find the code on the Prices sheet and compare the price, and search the Prices sheet for the codes in rows that say "Code not found".
โ This guide is general information. Yudum cannot be held responsible for the outcome of following it; for official procedures always rely on the institution's own statement. Steps and fees change over time.
๐ฌ Comment on this articleShare what you think and join the comments below.Write a comment โ















