IFERROR in an Excel test: use it, but don't hide mistakes
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) | Sales | Rate (Rates sheet) |
|---|---|---|
| Ana | 20,000 | 5% |
| Ben | 15,000 | 4% |
Dana (trailing space) | 18,000 | 6% (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")
TRIMremoves the stray space, so Dana matches.IFNAonly catches "not found". A typo in the formula still shows as an error, which you want.- "Check" shows up in the sheet where you can see it. SUM skips text, so count the flags before you trust the total.
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
- Expected error with a known meaning: handle it, and say so in a note.
- Lookup miss: flag it. Don't turn it into 0.
- Before you finish, count the flags:
=COUNTIF(D:D,"Check").
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.