The Excel ERROR.TYPE function returns a number that corresponds to a specific error value, helping you identify and handle errors in formulas. It takes a single argument—the error value—and returns 1 for #NULL!, 2 for #DIV/0!, 3 for #VALUE!, 4 for #REF!, 5 for #NAME?, 6 for #NUM!, 7 for #N/A, and #N/A for any other error. This guide walks you through using ERROR.TYPE effectively, from basic syntax to advanced error handling with IFERROR and ISERROR.
What You'll Need
- Microsoft Excel (any modern version: 2010 or later, Microsoft 365, or Excel for Mac). The function works the same across versions, though menu labels may differ slightly.
- A worksheet with at least one formula that may produce an error (or you can create one for practice).
- Basic familiarity with Excel formulas and cell references.
Step-by-Step
- Understand the syntax: The function is written as
=ERROR.TYPE(error_val), where error_val is the error value or a reference to a cell containing an error. For example,=ERROR.TYPE(#DIV/0!)returns 2. - Create a test error: In cell A1, enter
=1/0to produce a #DIV/0! error. In cell A2, enter=ERROR.TYPE(A1). The result should be 2. - Use ERROR.TYPE directly with an error value: You can also hard-code the error, e.g.,
=ERROR.TYPE(#N/A)returns 7. This is useful for testing or documentation. - Combine with IF to handle specific errors: For example,
=IF(ERROR.TYPE(A1)=2, "Divide by zero", "Other error")returns a custom message when A1 contains #DIV/0!. - Use with ISERROR for generic error detection:
=IF(ISERROR(A1), ERROR.TYPE(A1), "No error")returns the error code if A1 has an error, otherwise "No error". - Apply to a range with array formulas (optional): In Excel 365, you can use
=ERROR.TYPE(A1:A10)to return an array of error codes, but this requires dynamic arrays. For older versions, use Ctrl+Shift+Enter. - Integrate with IFERROR for cleaner handling: While ERROR.TYPE identifies the error, IFERROR can replace it with a value. For example,
=IFERROR(A1, "Error occurred")hides the error but doesn't tell you which one. Use ERROR.TYPE when you need to know the specific error. - Test with different error types: Create cells with #VALUE! (e.g.,
="a"+1), #REF! (e.g., delete a referenced cell), #NAME? (e.g.,=UNKNOWN()), #NUM! (e.g.,=SQRT(-1)), and #NULL! (e.g.,=SUM(A1 A2)with a space). Check that ERROR.TYPE returns the correct number for each. - Use in conditional formatting (advanced): You can set a rule to highlight cells where
=ERROR.TYPE(A1)=2to flag division errors visually. - Document your error handling: Add comments or a legend to explain the error codes, especially if sharing the workbook.
Common Mistakes
- Passing a non-error value: If the argument is not an error, ERROR.TYPE returns #N/A. For example,
=ERROR.TYPE(5)returns #N/A. - Forgetting that ERROR.TYPE returns #N/A for unrecognized errors: Custom errors or errors from add-ins may not map to the standard numbers, so ERROR.TYPE returns #N/A.
- Using ERROR.TYPE without handling its own errors: If the referenced cell is empty or contains a non-error, ERROR.TYPE returns #N/A, which can propagate. Wrap it in IFERROR if needed.
- Confusing ERROR.TYPE with ISERROR: ISERROR returns TRUE/FALSE, while ERROR.TYPE returns a number. Use the right one for your logic.
- Assuming ERROR.TYPE works on error text: If a cell contains the text "#DIV/0!" as a string, ERROR.TYPE will not recognize it as an error; it must be an actual error value.
Tips
- Use ERROR.TYPE in combination with CHOOSE to return descriptive messages:
=CHOOSE(ERROR.TYPE(A1), "Null", "Div/0", "Value", "Ref", "Name", "Num", "N/A"). - When debugging complex formulas, temporarily use ERROR.TYPE to identify which error is occurring.
- Remember that ERROR.TYPE is not volatile; it recalculates only when the referenced cell changes.
- For Excel 2013 and later, IFERROR is often simpler for error suppression, but ERROR.TYPE gives you more control for specific handling.
- Use named ranges or tables to make your error-handling formulas more readable.
Troubleshooting
- ERROR.TYPE returns #N/A: The argument is not an error value. Check that the cell actually contains an error (like #DIV/0!) and not text that looks like one.
- Formula returns unexpected number: Verify the error type. For example, #VALUE! returns 3, but if you see 2, the error might be #DIV/0!.
- ERROR.TYPE not working in array formulas: In older Excel versions, array-entered formulas may need Ctrl+Shift+Enter. In Excel 365, dynamic arrays handle it automatically.
- Error codes differ in other spreadsheet apps: Google Sheets and LibreOffice may have different mappings; ERROR.TYPE is Excel-specific.
- Cannot use ERROR.TYPE on a range without array entry: If you get a #VALUE! error, you may need to enter as an array formula or use a single cell reference.
Frequently Asked Questions
What does ERROR.TYPE return for #N/A?
It returns 7.
Can ERROR.TYPE handle custom errors?
No, it returns #N/A for any error not in the standard list.
Is ERROR.TYPE available in Excel for Mac?
Yes, it works the same in Excel for Mac.
How is ERROR.TYPE different from IFERROR?
IFERROR replaces an error with a specified value, while ERROR.TYPE identifies the error number for custom handling.
Can I use ERROR.TYPE with VLOOKUP?
Yes, you can wrap VLOOKUP in ERROR.TYPE to detect if it returns #N/A, e.g., =ERROR.TYPE(VLOOKUP(...)).
Does ERROR.TYPE work with errors from external links?
It works if the error is a standard Excel error; otherwise it returns #N/A.