ERROR.TYPE Function Guide
Master ERROR.TYPE to identify Excel errors, build custom messages, and create robust error-handling logic. Complete guide with examples.
=ERROR.TYPE(error_val)Quick Answer
ERROR.TYPE function ERROR.TYPE function returns a number (1-7) identifying Excel's seven standard error types like #N/A, #VALUE!, or #DIV/0!. Use syntax `=ERROR.TYPE(error_val)` where error_val is a cell reference or formula that may contain an error. Combine with CHOOSE to create custom error messages instead of displaying cryptic error codes.
=ERROR.TYPE(error_val)Practical Examples
Identifying Different Error Types
Understanding which error code corresponds to which error
Creating User-Friendly Error Messages
Replace cryptic error codes with helpful messages
Different Actions Based on Error Type
Execute different fallback logic depending on the error
Building an Error Audit Trail
Track and categorize all errors in a large dataset
Platform-Agnostic Error Management
Handle errors consistently across Excel and Google Sheets
Common Errors and Solutions
ERROR.TYPE returns #N/A instead of expected number
ERROR.TYPE returns #N/A when the input value is NOT an error. This is the function's way of indicating "no error detected." Many users expect a number or text message, but #N/A is the correct response for non-error values.
Wrap ERROR.TYPE in IFERROR or IF(ISERROR(...)) to handle valid values: ```excel // Instead of this: =ERROR.TYPE(A1) // Returns #N/A if A1 = 100 // Use this: =IFERROR(ERROR.TYPE(A1), "No error") // Or this: =IF(ISERROR(A1), ERROR.TYPE(A1), "Valid value") ``` **Best Practice:** ```excel =IF(ISERROR(A1), "Error type " & ERROR.TYPE(A1), "Value is valid: " & A1) ```
Always expect #N/A as a possible result. Design your error-handling logic to account for both error states (1-7) and non-error states (#N/A). Use ISERROR as a pre-check before applying ERROR.TYPE.
Example:
Formula returns #VALUE! error
ERROR.TYPE returns #VALUE! when you pass a direct value instead of a reference to an error. For example, =ERROR.TYPE("text") returns #VALUE! because "text" is not an error value, and ERROR.TYPE expects either an error value or a formula that might produce one.
Use cell references or formulas that can produce errors: ```excel // Wrong: =ERROR.TYPE(100) // Returns #N/A (valid value) =ERROR.TYPE("text") // Returns #VALUE! // Correct: =ERROR.TYPE(A1) // Where A1 contains #N/A =ERROR.TYPE(10/0) // Produces #DIV/0!, returns 2 =ERROR.TYPE(VLOOKUP("X",B:C,2,0)) // May produce #N/A ``` **Quick Fix:** ```excel // Test all error types =ERROR.TYPE(NA()) // Returns 7 (#N/A) =ERROR.TYPE(1/0) // Returns 2 (#DIV/0!) ```
Always reference cells or formulas, not static values. If testing, use formulas that generate errors: =ERROR.TYPE(1/0) for #DIV/0!, =ERROR.TYPE(NA()) for #N/A.
Example:
Custom messages display incorrectly
Mismatching error codes with CHOOSE function positions. CHOOSE is 1-indexed, and ERROR.TYPE returns 1-7, so the arrays must align perfectly. Common mistake: forgetting that CHOOSE's first argument is the index, leading to off-by-one errors.
Verify your CHOOSE array matches ERROR.TYPE codes exactly: ```excel // Wrong - misaligned messages =CHOOSE(ERROR.TYPE(A1), "Division by zero", // Position 1, but should be NULL "Null error", // Position 2, but should be DIV/0 ...) // Correct - properly aligned =CHOOSE(ERROR.TYPE(A1), "NULL intersection", // 1 = #NULL! "Division by zero", // 2 = #DIV/0! "Invalid value", // 3 = #VALUE! "Invalid reference", // 4 = #REF! "Unknown name", // 5 = #NAME? "Invalid number", // 6 = #NUM! "Value not available") // 7 = #N/A ``` **Reference Table:** | Code | Error | Message Template | |------|-------|------------------| | 1 | #NULL! | "Range intersection error" | | 2 | #DIV/0! | "Division by zero" | | 3 | #VALUE! | "Invalid value type" | | 4 | #REF! | "Invalid cell reference" | | 5 | #NAME? | "Unrecognized name" | | 6 | #NUM! | "Invalid numeric value" | | 7 | #N/A | "Value not available" |
Create a reference table mapping error codes to messages. Test each error type individually to verify correct message display.
Example:
Best Practices and Advanced Tips
Combine with INDIRECT for Dynamic Error Analysis
Use ERROR.TYPE with INDIRECT to analyze errors across multiple sheets dynamically. For example, =ERROR.TYPE(INDIRECT("Sheet" & A1 & "!B2")) checks specific cells across different sheets based on a sheet number in A1. This technique is invaluable for error monitoring in multi-sheet workbooks or consolidated reports.
Create Error Type Constants for Readability
Define named ranges for error codes to make formulas self-documenting. Create names like ERROR_NA=7, ERROR_DIV0=2, etc. Then use IF(ERROR.TYPE(A1)=ERROR_NA, ...) instead of remembering numeric codes. This dramatically improves formula readability and maintenance, especially in complex workbooks shared across teams.
Build Error-Resilient Array Formulas
In Excel 365, combine ERROR.TYPE with FILTER to create arrays that exclude certain error types while preserving others. For example, =FILTER(A:A, ERROR.TYPE(A:A)<>7) removes #N/A errors but keeps other errors visible for debugging. This selective filtering is powerful for data cleaning while maintaining error visibility.
Implement Graduated Error Responses
Create tiered error handling that responds differently based on error severity. Treat #REF! and #NAME? as critical (invalid formula structure), #N/A and #DIV/0! as data issues (fixable by users), and #VALUE! as input problems. Route critical errors to immediate alerts while logging data issues for batch review.
Use with Data Validation for Input Control
Combine ERROR.TYPE with data validation to prevent users from entering formulas that produce specific errors. Create validation rules that reject #DIV/0! or #VALUE! errors while allowing #N/A (acceptable for incomplete lookups). This proactive approach prevents error propagation in shared workbooks.
Need Help with ERROR.TYPE Function Guide?
Stop struggling with formula syntax. Use AskFormulas to generate validated formulas instantly with our AI-powered tool.
Example Excel formula:
Related Formulas
Master Excel's IFERROR function to handle errors gracefully. Replace #N/A, #DIV/0!, #VALUE! and other errors with custom values or blank cells.
Master the IFNA function to handle #N/A errors gracefully in Excel and Google Sheets. Learn syntax, examples, and best practices for error-free spreadsheets.
The ISERROR function checks if a value or formula results in any Excel error and returns TRUE or FALSE. Master error detection and handling.
The ISNA function checks if a value or formula returns the #N/A error and returns TRUE or FALSE. Master #N/A error detection for cleaner lookups.