Smart Systems for Home

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

Excel Find Return 0 If Not Found: Easy Formula Guide

· 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

To make Excel return a 0 instead of an error when a value is not found, wrap your lookup formula in the IFERROR function. For example, using =IFERROR(VLOOKUP(A2, D:E, 2, FALSE), 0) tells Excel to perform the search, but if the result is an error (like #N/A), it should display 0 instead. This is essential for maintaining clean datasets and ensuring that subsequent mathematical calculations, such as sums or averages, do not break due to error values.

What You'll Need

  • A computer with Microsoft Excel installed (any modern version).
  • A dataset containing a lookup value (the thing you are searching for) and a table array (the place where the data is stored).
  • Basic familiarity with selecting cells and entering formulas.

Step-by-Step

  1. Identify Your Base Formula: Before you can handle the "not found" error, you need a working lookup formula. The most common choices are VLOOKUP, XLOOKUP, or INDEX/MATCH. For this guide, we will use VLOOKUP as the primary example. A standard VLOOKUP looks like this: =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]).
  2. Test the Formula: Enter your standard lookup formula into a cell. If the value exists in your table, Excel will return the correct result. If the value does not exist, Excel will return the #N/A error. This error occurs because Excel cannot find the specific match you requested.
  3. Apply the IFERROR Wrapper: To replace that #N/A with a 0, you must wrap the entire formula inside the IFERROR function. The syntax for IFERROR is =IFERROR(value, value_if_error).
  4. Insert the Formula: Modify your cell entry to look like this: =IFERROR(VLOOKUP(A2, D:E, 2, FALSE), 0). In this example, VLOOKUP(A2, D:E, 2, FALSE) is the "value" being checked, and 0 is the "value_if_error".
  5. Confirm the Result: Press Enter. Now, if the lookup value in cell A2 is found in the range D:E, you will see the corresponding value from the second column. If it is not found, the cell will simply display 0.
  6. Drag to Fill: Hover your mouse over the bottom-right corner of the cell until the cursor turns into a small black cross (the fill handle). Click and drag downward to apply this logic to all other rows in your column.
  7. Verify Data Types: Ensure the cell is formatted as a Number or General. If the cell is formatted as Text, the 0 may be treated as a character rather than a numeric value, which could affect your totals.

Common Mistakes

One of the most frequent errors is placing the 0 inside the VLOOKUP function itself rather than as the second argument of the IFERROR function. VLOOKUP does not have a built-in "if not found" argument; it only has the range_lookup (TRUE/FALSE) argument. If you put a 0 where the range_lookup should be, you are simply telling Excel to perform an approximate match, which will not stop the #N/A error from appearing if the value is completely missing.

Another common mistake is confusing IFERROR with IFNA. While IFERROR catches every possible error (including #VALUE!, #REF!, and #DIV/0!), IFNA only catches the #N/A error. While using IFERROR is generally easier, it can sometimes hide genuine mistakes in your formula. For instance, if you accidentally delete a column and create a #REF! error, IFERROR will simply show a 0, and you might not realize your formula is broken. If you only want to handle "missing data" and not "broken formulas," IFNA is the more precise choice.

Users also frequently forget to set the final argument of VLOOKUP to FALSE (or 0). If this is left as TRUE or omitted, Excel performs an approximate match. This means if the exact value isn't found, Excel will return the next largest value that is less than your lookup value. This can lead to the formula returning a "wrong" result instead of returning an error, which means your IFERROR function will never trigger because no error was actually generated.

Tips

If you are using a newer version of Excel (Office 365 or Excel 2021), you should consider using XLOOKUP instead of VLOOKUP. XLOOKUP has a built-in argument for handling missing values, eliminating the need for the IFERROR wrapper entirely. The syntax is =XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found]). To return a 0, you would simply write: =XLOOKUP(A2, D:D, E:E, 0). This is cleaner, faster, and less prone to errors.

When working with large datasets, avoid referencing entire columns (like D:E) if you know exactly where your data ends. Referencing D1:E1000 is more efficient for Excel's calculation engine than referencing over a million rows. This prevents your workbook from lagging when you have thousands of IFERROR formulas running simultaneously.

If you want the cell to appear blank instead of showing a 0, you can replace the 0 in the IFERROR formula with double quotes: =IFERROR(VLOOKUP(A2, D:E, 2, FALSE), ""). This is often preferred for professional reports where a column of zeros can look cluttered or confusing to the reader.

Troubleshooting

If your formula is still returning #N/A despite using IFERROR, check your parentheses. The most common cause is closing the parenthesis too early. The structure must be =IFERROR( [Entire Formula] , 0 ). If you write =IFERROR(VLOOKUP(A2, D:E, 2, FALSE)) , 0, the 0 is outside the function and will be ignored or cause a syntax error.

If the formula returns a 0 even when you know the value exists, check for leading or trailing spaces in your data. A lookup value of "Apple" will not match a cell that contains "Apple " (with a space at the end). You can fix this by wrapping your lookup value in the TRIM function: =IFERROR(VLOOKUP(TRIM(A2), D:E, 2, FALSE), 0). This removes unnecessary spaces and ensures a proper match.

Check for data type mismatches. If your lookup value is stored as a number but the table array contains the same number stored as text, Excel will not find a match. You can tell if a number is stored as text if there is a small green triangle in the top-left corner of the cell. To fix this, select the column, go to the Data tab, select Text to Columns, and click Finish immediately to convert the text back into numbers.

If the formula returns 0 but you expected a different value, check if the cell being returned is actually empty. In Excel, if a VLOOKUP successfully finds a match but the corresponding cell in the return column is blank, Excel returns a 0 by default. This is different from the IFERROR 0. To distinguish between a "not found" 0 and a "blank cell" 0, you may need a more complex IF statement combined with ISBLANK.

Frequently Asked Questions

Can I return text like "Not Found" instead of 0?

Yes. Simply replace the 0 in the IFERROR formula with the text you want, enclosed in double quotes. For example: =IFERROR(VLOOKUP(A2, D:E, 2, FALSE), "Not Found").

Does IFERROR slow down my spreadsheet?

In very large workbooks with tens of thousands of rows, any wrapper function adds a small amount of calculation time. However, for most users, the impact is negligible. Using XLOOKUP is slightly more efficient than wrapping VLOOKUP in IFERROR.

What is the difference between IFERROR and IFNA?

IFERROR catches all errors (#N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, #NULL!). IFNA only catches the #N/A error. Use IFNA if you want to be alerted when your formula is fundamentally broken (like a deleted reference) while still handling missing data.

Why does my VLOOKUP return 0 when the cell is empty?

This is default Excel behavior. If the lookup finds a match but the cell it pulls from is empty, it treats that emptiness as a zero. This happens regardless of whether you use IFERROR or not.

Can I use this with the INDEX and MATCH functions?

Yes. The process is identical. Wrap the entire INDEX/MATCH combination inside the IFERROR function: =IFERROR(INDEX(E:E, MATCH(A2, D:D, 0)), 0).