How to Errortype Function in Excel
Learn multiple Excel methods to identify and work with error types, using the ERRORTYPE function plus modern error-handling techniques, complete with step-by-step examples and practical applications.
How to Errortype Function in Excel
Why This Task Matters in Excel
Errors are inevitable in every sizable spreadsheet. Whenever you link dozens of worksheets, import data from external systems, or build nested formulas, you run the risk of getting [#DIV/0!], [#N/A], [#VALUE!], or other unpleasant results. For analysts, accountants, marketers, supply-chain planners—basically anyone who lives in Excel—being able to recognize exactly which error appeared and react accordingly is critical for maintaining data integrity.
Imagine a regional sales dashboard that aggregates daily transactions. One division added a new product code that does not exist in your lookup table, but you do not notice until the dashboard shows [#N/A] everywhere. Or picture a financial model that investors read: a single division by zero cascades throughout the workbook, inflating risk indicators and destroying credibility. By learning to diagnose error types programmatically, you can intercept issues early, present user-friendly messages, and keep dashboards functioning.
Industry scenarios abound. In healthcare, quality-of-care metrics sourced from multiple data feeds may contain missing values. In logistics, distance calculations might reference blank coordinates, resulting in [#NUM!] errors. In e-commerce, dynamic discount formulas can return [#VALUE!] if a text field accidentally slips into a numeric calculation. The ERRORTYPE function shines in all those situations because it converts cryptic Excel error values into simple numeric codes. Combined with functions such as IF, LET, SWITCH, and custom error messages, you can build resilient reporting layers that intelligently guide end-users to root causes.
If you choose to ignore error classification altogether, downstream formulas can propagate bad data, conditional formatting may fail, and automated VBA or Power Query processes might break unexpectedly. Mastering ERRORTYPE connects seamlessly to other essential skills—robust data validation, error-proof lookup formulas, dynamic arrays, and professional-grade dashboards—making you a more confident Excel power user.
Best Excel Approach
The most direct way to identify what went wrong in a cell is to wrap that cell with the ERRORTYPE function. ERRORTYPE returns an integer from 1 to 8, each corresponding to a specific Excel error. Because the output is numeric, you can easily embed it in logical tests, dynamic error messages, or SWITCH statements to translate the code back into friendly language.
Syntax
=ERRORTYPE(error_val)
- error_val — A cell reference, formula, or literal error value to evaluate. If the argument is not an error, ERRORTYPE returns [#N/A].
Why this approach is best
- Direct interpretation: It reports the underlying error even when the cell is hidden by conditional formatting or custom number formats.
- Compatible with logical branching: The numeric code plugs right into IF or SWITCH to decide what to display.
- Lightweight: It performs a single lookup instead of nesting multiple ISERROR or IFERROR layers, which can slow large models.
When ERRORTYPE is appropriate
- Auditing complex workbooks to reveal hidden problems.
- Building interactive dashboards where user-friendly error labels are required.
- Debugging external data imports that sometimes change data structure.
Alternative in newer Excel versions
Modern dynamic array formulas can also leverage the ERROR.TYPE function inside LET and LAMBDA wrappers for more modular analysis:
=LET(
Code, ERRORTYPE(A2),
Message, SWITCH(Code,
1,"Division by zero",
2,"Not available",
3,"Reference",
4,"Value",
5,"Name",
6,"Number",
7,"N/A returned by ERRORTYPE",
8,"Null intersection",
"No error"),
Message)
Parameters and Inputs
- error_val (required)
– Data type: Can be a direct reference such as [B3], a formula likeA1/A2, or an explicit error constant typed into the formula such as#VALUE!.
– Expected content: One of Excel’s eight documented error types. If the supplied cell currently shows a regular number, text, or Boolean TRUE/FALSE, ERRORTYPE itself will output [#N/A] to indicate “no error.”
Preparation guidelines
- Cells must NOT be formatted as text containing something that merely looks like an error. For example, the string \"#DIV/0!\" will not be detected.
- Ensure lookup tables or data imports have refreshed, otherwise stale formulas may produce multiple cascading errors that complicate interpretation.
- If you feed ERRORTYPE the result of an array, be mindful of spill areas—point to the first cell in the spill range or wrap inside INDEX to retrieve a scalar element.
Edge-case inputs
- Blank cells: ERRORTYPE treats them as no error; output is [#N/A].
- Logical TRUE/FALSE: Also considered no error.
- Named ranges defined as error constants will work, but volatile names could repeatedly recalculate, impacting performance.
Step-by-Step Examples
Example 1: Basic Scenario
Suppose you have a simple ratio analysis worksheet. In [B2] you calculate “Profit per Unit”:
=B2/C2
If [C2] (Units Sold) is zero, Excel returns [#DIV/0!]. To automatically flag the type of error:
- Enter sample data:
- [A2] = \"Widget A\"
- [B2] = 5000
- [C2] = 0
- In [D2] type:
=ERRORTYPE(B2/C2)
-
The formula returns 2 (division by zero).
-
Add a friendly explanation for the end user in [E2]:
=IF(D2=2,"Units Sold cannot be zero, please correct input.","")
Why it works
ERRORTYPE intercepts the error code before IF tries to compare anything. The numeric value 2 corresponds to [#DIV/0!], allowing you to give precise guidance.
Variations
- Replace IF with SWITCH for multiple error messages.
- Wrap the income statement in a SUMIFS to exclude rows whose ERRORTYPE is not [#N/A].
Troubleshooting
If you get [#N/A] but expected a numeric code, check that the original cell truly contains an error and not an empty string returned by a formula such as IFERROR(original,"").
Example 2: Real-World Application
Case study: Regional sales dashboard imports CSV files daily. After a corporate rebranding, some product IDs changed. A VLOOKUP formula now yields [#N/A] for missing IDs.
-
Raw data table in [SalesData] sheet:
Columns—Date, ProductID, Quantity, Revenue. -
Lookup table in [Products] sheet:
Columns—ProductID, Category, LaunchDate. -
In dashboard sheet, category retrieval formula:
=VLOOKUP([@ProductID],Products!A:B,2,FALSE)
- In [H2], capture error type for the same row:
=ERRORTYPE(VLOOKUP([@ProductID],Products!A:B,2,FALSE))
- Add a helper column with explanatory text in [I2]:
=IF(H2=7,"Product ID missing in lookup table","")
- Create a PivotTable that filters to rows where [I] is not blank. This quickly summarizes missing IDs by region.
Business impact
Customer-facing dashboards continue to show valid products, while the issue list helps procurement update the master product table, preventing lost revenue opportunities.
Integration with other features
- Conditional formatting burn-down chart: highlight any ERRORTYPE code 7 in red.
- Power Query append: After cleaning missing IDs, refresh all connections—ERRORTYPE instantly returns [#N/A], indicating resolution.
Performance considerations
ERRORTYPE adds minimal overhead. Even at 100,000 rows, the calculation chain remains fast because it only processes cells already containing an error.
Example 3: Advanced Technique
Dynamic array spill range audit: You have a complex LET-based financial projection that outputs an array in [F5]. Occasionally, invalid assumptions generate [#NUM!] errors within the array, but the top-left cell remains a number, so casual inspection misses them.
- In any empty cell, build this formula:
=IFERROR(
LET(
spill, F5#,
codes, ERRORTYPE(spill),
maxCode, MAX(codes),
IF(ISNUMBER(maxCode),maxCode, "No errors")
),
"Spill contains impossible errors")
- Explanation:
F5#references the entire spill range.ERRORTYPE(spill)returns an array of codes matching the array’s shape.MAXextracts the largest code. If all elements are regular values,codeswill be [#N/A]; then MAX returns [#N/A] which is caught by ISNUMBER.
- Advanced improvement—return the coordinates of the first error:
=LET(
spill, F5#,
codes, ERRORTYPE(spill),
errPos, XMATCH(TRUE,ISNUMBER(codes)),
errAddress, IF(ISNUMBER(errPos), INDEX(SHEETPOS(spill),errPos), "No error"),
errAddress)
(Requires Office 365 with XMATCH and LAMBDA helper defined for SHEETPOS.)
Professional tips
- Use this audit cell as a workbook-level “traffic light”—green when no errors, red showing numeric code.
- Combine with Data Validation to prohibit saving if ERRORTYPE finds code 4 (value error) in key model areas.
Tips and Best Practices
- Pair ERRORTYPE with SWITCH instead of nested IFs for readable branching.
- Hide raw error codes from end users—use helper columns that translate numbers into clear text.
- Cache results in helper columns rather than recalculating inside every final formula, especially on large data sets.
- Use conditional formatting icons triggered by numeric codes to provide at-a-glance health indicators.
- Keep an “Error Key” table listing code-to-description mapping; reference it with VLOOKUP or XLOOKUP for easy maintenance.
- When publishing dashboards to Power BI or Excel Online, test how ERRORTYPE interacts with external connectors—refresh order can change which sheet calculates first.
Common Mistakes to Avoid
- Treating [#N/A] returned by ERRORTYPE as an error in itself. Remember: [#N/A] from ERRORTYPE usually means no error in the evaluated cell.
- Feeding text that merely looks like an error, such as \"#VALUE!\", into ERRORTYPE. The function requires genuine error data type, not a string.
- Forgetting to lock cell references (use absolute addressing) in helper columns, causing ERRORTYPE to point to the wrong cell when copied down.
- Cascading multiple volatile functions with ERRORTYPE, such as NOW or RAND. This forces unnecessary recalculation every time the sheet changes.
- Ignoring case where the original formula is wrapped in IFERROR returning blank quotes \"\". That prevents ERRORTYPE from ever seeing the original error. Instead, capture ERRORTYPE first, then decide whether to mask it.
Alternative Methods
Although ERRORTYPE is straightforward, other techniques can classify or suppress errors.
| Method | How it Works | Pros | Cons | Ideal Use-Case |
|---|---|---|---|---|
| ISERROR + CHOOSE | Wrap ISERROR within nested IF or CHOOSE statements. | Familiar to many users; no numeric codes to remember. | Requires multiple evaluations of the same formula; less granular (does not distinguish error types). | Quick “any error?” checks when specific error type does not matter. |
| IFERROR / IFNA | Return fallback value when error occurs. | Compact; widely used. | Masks the error rather than identifying it; troubleshooting becomes harder. | Final presentation layer where user-friendly text replaces error symbols. |
| ERROR.TYPE (legacy name) | Same as ERRORTYPE for users on older versions. | Compatible with Excel 2003 macros. | Deprecated in documentation; inconsistent naming may confuse teams using modern versions. | Maintaining legacy workbooks. |
| Power Query errors panel | Detects errors during ETL steps. | Visual; separate from Excel grid. | Requires data model refresh; not accessible to worksheet formulas. | Large-scale data import pipelines. |
When to switch methods
- If you just need to show “N/A” instead of [#N/A], IFNA is simpler.
- If you must differentiate between [#DIV/0!] and [#VALUE!], choose ERRORTYPE.
- For one-off manual data cleansing, Power Query gives a richer interface.
FAQ
When should I use this approach?
Use ERRORTYPE when you must know which error occurred rather than simply hiding it. Examples: auditing complex financial models, generating targeted instructions for end users, or building automated workflows that react differently to each error code.
Can this work across multiple sheets?
Yes. Point error_val to a fully qualified address such as ='Sheet2'!B12. You can also wrap 3-D references or INDIRECT. If you roll up multiple sheets, consolidate values first with functions like SUM or TEXTJOIN, then apply ERRORTYPE to the summary cell.
What are the limitations?
ERRORTYPE only evaluates one value at a time unless you pass it a spill range in newer Excel versions. It cannot distinguish errors inside an external link that has not been refreshed. Also, it returns [#N/A] when the input is not an error, which can be misinterpreted.
How do I handle errors?
Classify with ERRORTYPE, translate the numeric code to a message via SWITCH, then either correct source data or use IFERROR to present fallback values. In some cases, you might push the issue to Power Query’s “Remove Errors” step.
Does this work in older Excel versions?
The function exists as ERROR.TYPE in versions prior to Excel 2007. Both names are recognized in modern builds for backward compatibility, but macros recorded in old workbooks may retain the underscore format.
What about performance with large datasets?
ERRORTYPE is lightweight because it short-circuits if the input is already an error value. Still, cache intermediary results in a helper column rather than wrapping the main formula every time. Use manual calculation mode when auditing hundreds of thousands of rows.
Conclusion
Mastering ERRORTYPE transforms how you audit, debug, and present spreadsheets. Instead of guessing what went wrong or blindly masking errors with IFERROR, you obtain precise diagnostic codes and can react intelligently—guiding users, fixing formulas, or flagging data issues long before they hit management dashboards. Add this skill to your toolbox and you will build more reliable, professional Excel solutions. Next, explore pairing ERRORTYPE with dynamic arrays, LAMBDA functions, and structured references to take error handling to an enterprise level of sophistication.
Related Articles
How to Show the 10 Most Common Text Values in Excel
Learn multiple Excel methods to list the 10 most frequent text values—complete with step-by-step examples, business use cases, and expert tips.
How to Abbreviate Names Or Words in Excel
Learn multiple Excel methods to abbreviate names or words with step-by-step examples and practical applications.
How to Abbreviate State Names in Excel
Learn multiple Excel methods to abbreviate state names with step-by-step examples, professional tips, and real-world applications.