Excel Supreme

Excel track · Exercise 66 of 86 Paid

IFERROR: catch the error, show your text

Replace a failed lookup with words you chose, and know which faults those words will hide.

Intermediate

Two prices and a missing SKU

Read-only data · answer in B5

In B5, look up the price of the SKU in A4, and show "no price" if the lookup fails.

AB
1SKUPrice
2TX-10119.99
3TX-10214
4TX-109
5Price

Download this grid (.xlsx) Two tabs: the grid you see, and the answer.

B5

What it does

IFERROR takes two arguments: the calculation that might fail, and what to show when it does. Anything that goes wrong inside the first argument is replaced by the second. Here the lookup on TX-109 finds nothing in A2:B3 and would return #N/A, so the cell reads no price instead.

IFERROR catches every error the same way, which is wider than a lookup miss. A reference that no longer points anywhere, or arithmetic on text, gets the same two words as a code that is simply absent. A broken formula then reads like missing data.

Put the guard around the part that can fail. The SKU is read from A4, so a different code changes the answer without touching the formula. Arithmetic left outside the IFERROR still returns an error instead of text.

Syntax

=IFERROR(value, value_if_error)

Worked example

On Two prices and a missing SKU, =IFERROR(VLOOKUP(A4,A2:B3,2,FALSE),"no price") returns no price.

=IFERROR(VLOOKUP(A4,A2:B3,2,FALSE),"no price")

Common errors

Error codes for IFERROR
ErrorWhat it means and how to fix it
#N/AThe lookup finds nothing and no fallback is supplied, so the cell shows the error instead of words.
#VALUE!A number is added to the fallback text outside the wrapper, so the whole cell turns into #VALUE!.
Masked faultThe same fallback answers a broken reference too, so a formula fault prints as a missing price and nobody looks.

At work

A price list sent to a customer, where a discontinued code has to read as missing instead of #N/A.