Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel Lookup Guide: How to Use VLOOKUP and XLOOKUP

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Performing a lookup in Excel allows you to search for a specific value in one part of a spreadsheet and retrieve corresponding information from another location. This is primarily achieved using the VLOOKUP function or the more modern XLOOKUP function. To do a basic lookup, you need a unique identifier (like an ID number), a range of data to search through, and the column number containing the information you want to return.

What You'll Need

  • A computer with Microsoft Excel installed (Version requirements vary: XLOOKUP requires Microsoft 365 or Excel 2021+).
  • A dataset containing a "lookup value" (the piece of information you already know) and a "return value" (the information you are trying to find).
  • A structured table where the lookup value is located in the leftmost column (specifically for VLOOKUP).

Step-by-Step

Depending on your version of Excel, you will use either VLOOKUP (the industry standard) or XLOOKUP (the more flexible successor). Below are the detailed steps for both methods.

Method 1: Using VLOOKUP (Vertical Lookup)

  1. Organize Your Data: Ensure your source data is arranged vertically. The value you are searching for (the unique ID) must be in the very first column of the range you select. VLOOKUP cannot look to the left of the search column.
  2. Select the Destination Cell: Click the cell where you want the result to appear.
  3. Enter the Function: Type =VLOOKUP( into the cell.
  4. Define the Lookup Value: Click the cell that contains the value you want to search for (e.g., cell A2 containing an Employee ID). Follow this with a comma.
  5. Select the Table Array: Highlight the entire range of data that contains both the lookup column and the result column. For example, Sheet2!A2:D100. Follow this with a comma.
  6. Specify the Column Index Number: Count the columns in your selected range from left to right. If the data you want to retrieve is in the third column of your selection, type 3. Follow this with a comma.
  7. Set the Range Lookup: To find an exact match, type FALSE or 0. If you leave this blank or type TRUE, Excel will look for an approximate match, which often leads to errors in database lookups.
  8. Close and Execute: Type the closing parenthesis ) and press Enter.

Method 2: Using XLOOKUP (The Modern Way)

  1. Identify Your Arrays: Unlike VLOOKUP, XLOOKUP does not require the data to be in a specific order. You simply need to know which column contains the search key and which column contains the result.
  2. Enter the Function: Type =XLOOKUP( into your destination cell.
  3. Select the Lookup Value: Click the cell containing the value you are searching for. Follow this with a comma.
  4. Select the Lookup Array: Highlight only the single column where the search key exists. For example, Sheet2!A2:A100. Follow this with a comma.
  5. Select the Return Array: Highlight only the single column that contains the data you want to retrieve. For example, Sheet2!C2:C100. Follow this with a comma.
  6. Optional: Handle Missing Data: You can add a fourth argument to specify what Excel should display if no match is found. For example, type ,"Not Found".
  7. Close and Execute: Type the closing parenthesis ) and press Enter.

Common Mistakes

Many users encounter errors not because the formula is wrong, but because the data structure is incompatible. One of the most common mistakes is attempting to use VLOOKUP to find data to the left of the lookup column. VLOOKUP is strictly a "left-to-right" tool; if your ID is in Column B and the name is in Column A, VLOOKUP will fail. In these cases, you must either move the columns or use XLOOKUP.

Another frequent error is forgetting the FALSE argument in VLOOKUP. By default, VLOOKUP assumes you want an approximate match. If your data is not sorted in ascending order, an approximate match will return the wrong value or an error, even if the exact value exists in the list. Always use FALSE for unique identifiers like email addresses, SKU numbers, or employee IDs.

Data type mismatches are also a significant hurdle. If your lookup value is formatted as "Text" but the source table stores that same ID as a "Number," Excel will not recognize them as a match, resulting in a #N/A error. Both the search value and the source column must share the same data format.

Tips

To make your lookups more robust, use Absolute References. When you drag a VLOOKUP formula down a column, the table range also shifts down, which can lead to missing data. To prevent this, press F4 after selecting your table array to lock it (e.g., $A$2:$D$100). This ensures the formula always looks at the same set of cells regardless of where it is copied.

For those working with massive datasets, consider converting your source data into an Excel Table (Ctrl + T). When you reference a Table name instead of a cell range (like Table1 instead of A2:D100), the lookup range expands automatically as you add new rows. This removes the need to manually update your formulas every time the list grows.

If you are using a version of Excel that doesn't have XLOOKUP, you can combine INDEX and MATCH. This combination acts like a powerful version of VLOOKUP that can look in any direction and is generally faster for the computer to process in very large spreadsheets.

Troubleshooting

If your lookup is not working as expected, follow these steps in order:

  1. Check for Leading or Trailing Spaces: This is the most common cause of #N/A errors. A cell that looks like "123" might actually be "123 " (with a space at the end). Use the =TRIM() function on your data to remove invisible spaces.
  2. Verify Data Types: Select your lookup column and check the format in the Home tab. If one is "General" and the other is "Text," highlight the column, go to the Data tab, select Text to Columns, and finish the wizard without changing settings to force a format reset.
  3. Check the Column Index: In VLOOKUP, ensure your column number is relative to the selection, not the whole sheet. If your range starts at Column C and you want data from Column E, the index is 3, not 5.
  4. Confirm the Lookup Value Exists: Use Ctrl + F to manually search for the value in the source table. If Excel cannot find it manually, the formula cannot find it either.
  5. Check for Hidden Rows/Filters: Ensure that the data you are looking for isn't hidden by a filter, although lookups generally find hidden data, it can confuse the user during manual verification.

Frequently Asked Questions

What is the difference between VLOOKUP and XLOOKUP?

VLOOKUP requires the search value to be in the leftmost column and requires a column index number. XLOOKUP allows you to select the search and return columns independently, can look to the left, and defaults to an exact match.

Why am I getting a #N/A error?

This usually means the value you are looking for does not exist in the first column of your range, or there is a formatting mismatch (such as text vs. number) or hidden spaces in the cells.

Can I look up data from a different workbook?

Yes. When selecting your table array, you can click over to another open Excel file and highlight the range. Excel will automatically include the file path in the formula.

Can VLOOKUP return multiple columns of data?

A standard VLOOKUP returns only one value. To get multiple columns, you must write separate VLOOKUP formulas for each column, changing only the column index number for each.

How do I handle errors so the cell stays blank?

Wrap your lookup formula inside an =IFERROR() function. For example: =IFERROR(VLOOKUP(...), ""). This replaces the #N/A error with a blank cell or a custom message.

Does VLOOKUP work with horizontal data?

No, VLOOKUP is for vertical columns. If your data is arranged in horizontal rows, you should use the HLOOKUP (Horizontal Lookup) function or XLOOKUP, which handles both directions.