BBampaa

Lessons › Excel & Google Sheets

Excel & Google Sheets lesson

IFERROR

XLOOKUP fails, so IFERROR shows Not listed. When the lookup works, you get the price as normal.

Try this lesson free →
About 5–10 minutes · no sign-up needed

Example

Cable isn't in the price list, so a plain XLOOKUP shows #N/A. IFERROR catches the error and shows something useful instead:

=IFERROR(XLOOKUP(B4,H2:H5,I2:I5),"Not listed")

Typed into cell E4 of this sheet:

OrderProductQtyRevenuePricePer itemProductPrice
O101Earbuds270Earbuds35
O102Charger115Charger15
O103Cable327Phone case8
O104Phone case00Screen guard5
O105Screen guard420

Key points

IFERROR(Wrap any formula that might fail.
XLOOKUP(...)First: the formula to try.
"Not listed"Second: what to show if it fails. Text, 0, or a blank "".

Put together: =IFERROR(formula, fallback). It also stops #DIV/0! when you divide by a zero or empty cell.

Practice

Try each one in your head first, then open the answer.

1. In E4, look up the price for order O103. Show Not listed if the product isn't there.
=IFERROR(XLOOKUP(B4,H2:H5,I2:I5),"Not listed")
2. In F5, work out the price per item for order O104: revenue divided by quantity. Show 0 if it can't be worked out.
=IFERROR(D5/C5,0)
3. In E2, look up the price for order O101, showing Not listed if it's missing.
=IFERROR(XLOOKUP(B2,H2:H5,I2:I5),"Not listed")
4. In F5, work out the price per item for order O104 (revenue divided by quantity). Show 0 if it can't be worked out.
=IFERROR(D5/C5,0)
5. In E4, look up the price for order O103. If it's not in the price list, show Check.
=IFERROR(XLOOKUP(B4,H2:H5,I2:I5),"Check")

Learn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.

Try this lesson free →
About 5–10 minutes · no sign-up needed