Excel Case Take the free check

IFERROR in an Excel test: use it, but don't hide mistakes

By Excel Case ยท Updated

IFERROR makes a sheet look clean. In a test, it can also hide the exact problem the reviewer planted.

In short: =IFERROR(formula, value_if_error) replaces any error with something else. Use it only for errors you expect, like dividing by zero sales. For lookups, prefer IFNA and return a visible flag like "Check", not 0. Otherwise a missing match silently drops out of your total.

The test question

Brief: "Work out each rep's commission and the total." Rates are on a separate sheet.

Rep (Sales sheet)SalesRate (Rates sheet)
Ana20,0005%
Ben15,0004%
Dana (trailing space)18,0006% (listed as Dana)

The tempting answer

=B2*IFERROR(VLOOKUP(A2,Rates!A:B,2,FALSE),0)

No errors show. The total commission is 1,600. The real total is 2,680. "Dana " doesn't match "Dana", so the lookup fails and IFERROR quietly turns 1,080 of commission into 0.

A better answer

=IFNA(B2*VLOOKUP(TRIM(A2),Rates!A:B,2,FALSE),"Check")

When IFERROR is right

Margin % for a product with no sales this month: =IFERROR(C2/B2,"") or =IF(B2=0,"",C2/B2). The division by zero is expected, and a blank is the right answer. The IF version is clearer about why.

Quick rule for tests

Questions people ask

What is the difference between IFERROR and IFNA?

IFERROR catches every error type, including #DIV/0!, #VALUE! and #REF!. IFNA only catches #N/A, the "not found" error from lookups, so other mistakes stay visible.

Should I use IFERROR with VLOOKUP?

Only if you return something you'll notice, like "Check" or "Missing". Returning 0 or a blank hides missing matches and makes totals too low.

Does XLOOKUP need IFERROR?

No. XLOOKUP has its own fourth argument for "not found", for example =XLOOKUP(A2,Rates!A:A,Rates!B:B,"Check").

Now try one that marks itself

The free check gives you an email, a messy export and 10 minutes. It re-runs your formulas on data you haven't seen and shows what broke.

Start the free check

Keep practising