Smart Systems for Home

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

How to Use IF and VLOOKUP Together in Excel

· 5 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

Combining IF and VLOOKUP in Excel lets you return custom messages or alternate values when a lookup fails, making your spreadsheets smarter and more user-friendly. This technique prevents #N/A errors and allows dynamic responses based on whether data exists.

What You'll Need

  • Microsoft Excel (2010 or later, including Microsoft 365)
  • A table of data with at least two columns: a lookup column and a return column
  • A cell where you want the result to appear
  • Basic familiarity with Excel formulas and cell references

Step-by-Step

  1. Open your Excel workbook and ensure your data is organized in a vertical table format. For example, Column A should contain unique identifiers (like Product ID or Employee Name), and Column B should contain the corresponding values you want to retrieve (like Price or Department).
  2. Identify the cell where you want the result to appear. This is your output cell. For example, if you're looking up a product ID in cell E2, your result will show in F2.
  3. Click on the output cell (e.g., F2) and begin typing the formula: =IF(ISBLANK(E2),"",VLOOKUP(E2,A:B,2,FALSE)). This checks if the lookup value is empty and returns a blank if so, otherwise performs the lookup.
  4. Replace E2 with the cell containing your lookup value, A:B with the range covering your lookup column and return column, and 2 with the column number in your range that contains the data to return. Ensure the lookup column is always the leftmost column in your range.
  5. Press Enter. If the lookup value exists in the table, the matching result appears. If it doesn’t, you’ll see a blank (or your custom message) instead of #N/A.
  6. To return a custom message like "Not Found" instead of blank, change the formula to: =IF(ISBLANK(E2),"",IFERROR(VLOOKUP(E2,A:B,2,FALSE),"Not Found"))
  7. Copy the formula down to other cells by clicking the bottom-right corner of the result cell and dragging it down, or double-clicking the fill handle. Excel will automatically adjust the row references.
  8. Verify results by testing with known values, blank inputs, and invalid values. Ensure all lookup values are text or numbers consistently formatted (e.g., no leading spaces or mixed data types).

Common Mistakes

  • Using an incorrect column index in VLOOKUP — if your range is A:C and you want column C, use 3, not 2.
  • Forgetting to use FALSE for exact match — using TRUE or omitting it causes approximate matching, which can return wrong results if data isn’t sorted.
  • Including extra spaces in lookup values or table data — use TRIM() around lookup values if needed: =IFERROR(VLOOKUP(TRIM(E2),A:B,2,FALSE),"Not Found").
  • Referencing a range that doesn’t include the return column — if your lookup column is A and return column is C, your range must be A:C, not A:B.
  • Using IF without ISBLANK or IFERROR — plain IF(VLOOKUP(...)) will still show #N/A if the lookup fails.

Tips

  • Use named ranges for your lookup table (e.g., "ProductTable") to make formulas easier to read and maintain. Select your data, then go to Formulas > Define Name.
  • For large datasets, consider switching to XLOOKUP (available in Microsoft 365) — it’s more flexible and doesn’t require the lookup column to be first.
  • If your lookup values are numbers stored as text, convert them using VALUE() or reformat the cells as Number.
  • Always test your formula with blank, duplicate, and missing values before deploying it in production files.
  • Use conditional formatting to highlight cells where "Not Found" appears — this helps spot data gaps quickly.
  • For multiple criteria lookups, combine IF with INDEX and MATCH instead of VLOOKUP — VLOOKUP only works left-to-right.

Troubleshooting

If your formula returns #N/A despite using IFERROR, check the following:

  1. Ensure the lookup value exactly matches an entry in your table. Even a trailing space or different capitalization can break the match.
  2. Verify your lookup range includes all rows where data might exist. If you added new rows, update the range in your formula (e.g., change A:B to A:Z).
  3. Confirm that the column index number corresponds to the correct column within your range. If your range is D:G and you want column F, the index is 3, not 6.
  4. If using a table, convert it to a structured reference: =IFERROR(VLOOKUP(E2,ProductTable,2,FALSE),"Not Found") — this auto-expands as data grows.
  5. If the formula works for some rows but not others, check for mixed data types — e.g., one cell is "123" (text), another is 123 (number). Use VALUE() or TEXT() to standardize.
  6. If you’re on an older Excel version without IFERROR, use: =IF(ISNA(VLOOKUP(E2,A:B,2,FALSE)),"Not Found",VLOOKUP(E2,A:B,2,FALSE)) — this is longer but compatible.
  7. Restart Excel if formulas stop calculating — sometimes calculation mode switches to Manual. Go to Formulas > Calculation Options and set to Automatic.

Frequently Asked Questions

Can I use IF and VLOOKUP with multiple criteria?

VLOOKUP only supports single-column lookups. For multiple criteria, combine INDEX and MATCH with an array formula or use XLOOKUP with multiple criteria support in newer Excel versions.

Why does my VLOOKUP return the wrong value?

This happens when you use TRUE instead of FALSE for approximate matching, or when your lookup column isn’t sorted. Always use FALSE for exact matches unless you specifically need a range lookup.

Can I use this with text and numbers together?

Yes, as long as the data types match. If your lookup cell contains a number but your table stores it as text, convert one to match the other using TEXT() or VALUE().

What if my lookup table is on another sheet?

Reference the sheet name: =IFERROR(VLOOKUP(E2,Sheet2!A:B,2,FALSE),"Not Found"). Ensure the sheet name has no spaces; if it does, wrap it in single quotes: 'Sales Data'!A:B.

Does this work in Google Sheets?

Yes, the syntax is nearly identical. Google Sheets supports IF, VLOOKUP, and IFERROR the same way. Replace FALSE with 0 for exact match if needed, though FALSE still works.

Will this slow down my spreadsheet?

Using VLOOKUP across large ranges (e.g., A:Z) can slow performance. Limit ranges to specific columns (A1:B1000) instead of entire columns. If you have thousands of formulas, consider switching to INDEX/MATCH or Power Query for better efficiency.