ERROR.TYPE function
Returns a number that identifies which error a cell contains, e.g. 2 for #DIV/0! and 7 for #N/A, so formulas can react to each error differently.
Available in All versions of Excel, including Microsoft 365 and Excel for the web
In every Excel versionWorks in Google Sheets
Syntax
ERROR.TYPE(error_val)| Argument | What it means | |
|---|---|---|
error_val | Required | The value to test — usually a cell reference or a formula that may return an error. |
Returns: 1 for #NULL!, 2 for #DIV/0!, 3 for #VALUE!, 4 for #REF!, 5 for #NAME?, 6 for #NUM!, 7 for #N/A, 8 for #GETTING_DATA; newer Microsoft 365 errors return higher numbers. If the value is not an error, the result is #N/A.
How ERROR.TYPE works
Where ISERROR only tells you that something went wrong, ERROR.TYPE tells you what went wrong by returning a code number for each kind of error. That lets you show a specific message — "missing from price list" for #N/A, "no units sold" for #DIV/0! — rather than one generic warning.
The catch is that ERROR.TYPE itself returns #N/A when the cell is fine, because there is no error to classify. So in practice you either test for an error first with ISERROR, or wrap the call in IFERROR to turn "no error" into 0. A common pattern is =IF(ISERROR(B2), CHOOSE(ERROR.TYPE(B2), ...), B2).
Examples
1Identify a division-by-zero error
| A | B | C | |
|---|---|---|---|
| 1 | Check | Result | |
| 2 | Margin % | #DIV/0! | 2 |
| 3 | Lookup | #N/A | |
| 4 | Total | #VALUE! | |
| 5 | Units | 125 |
Result: 2
B2 contains #DIV/0!, which has code 2. B3 (#N/A) would give 7 and B4 (#VALUE!) would give 3.
2A specific message for missing lookups
| A | B | C | |
|---|---|---|---|
| 1 | Check | Result | |
| 2 | Margin % | #DIV/0! | |
| 3 | Lookup | #N/A | Missing from list |
| 4 | Total | #VALUE! | |
| 5 | Units | 125 |
Result: Missing from list
B3 holds #N/A (code 7), so the message points the reader to the lookup list instead of the formula.
3Return 0 when there is no error
| A | B | C | |
|---|---|---|---|
| 1 | Check | Result | |
| 2 | Margin % | #DIV/0! | |
| 3 | Lookup | #N/A | |
| 4 | Total | #VALUE! | |
| 5 | Units | 125 | 0 |
Result: 0
B5 holds the normal number 125. ERROR.TYPE returns #N/A for it, and IFERROR converts that into 0, meaning "no error".
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#N/A | The tested value is not an error. | Check with ISERROR first, or wrap in IFERROR. |
Tips
- Use CHOOSE to map codes to messages:
CHOOSE(ERROR.TYPE(B2), "Ranges don't meet", "Divide by zero", "Wrong type", "Broken reference", "Unknown name", "Bad number", "Not found"). - For the common "not found" case alone, IFNA or ISNA is simpler than checking for code 7.
Google Sheets
ERROR.TYPE also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
ERROR.TYPE in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Czech | CHYBA.TYP |
| Danish | FEJLTYPE |
| Dutch | TYPE.FOUT |
| Finnish | VIRHEEN.LAJI |
| French | TYPE.ERREUR |
| German | FEHLER.TYP |
| Hungarian | HIBA.TÍPUS |
| Italian | ERRORE.TIPO |
| Norwegian (Bokmål) | FEIL.TYPE |
| Polish | NR.BŁĘDU |
| Portuguese (Brazil) | TIPO.ERRO |
| Portuguese (Portugal) | TIPO.ERRO |
| Russian | ТИП.ОШИБКИ |
| Spanish | TIPO.DE.ERROR |
| Swedish | FEL.TYP |
| Turkish | HATA.TİPİ |