Skip to main content
ExcelERROR.TYPEInformationError HandlingDebuggingLogic

The Problem

Are you staring at a spreadsheet filled with cryptic Excel errors like #N/A, #DIV/0!, or #VALUE!? It's a common, frustrating sight that can bring even the most meticulously built models to a grinding halt. You know there's an issue, but often, the sheer variety of errors makes it difficult to implement a universal fix. How do you distinguish between a missing lookup value and an invalid calculation? How can you create intelligent formulas that react differently to each unique problem?

The generic ISERROR function tells you if an error exists, but it doesn't tell you what kind of error. This lack of specificity forces you into a "one-size-fits-all" error handling approach, which can be inefficient and sometimes even misleading. What if you need to re-lookup data only if it's a #N/A error, but perform a different action if it's a #DIV/0!? This is where the Excel ERROR.TYPE function becomes your indispensable tool. What is ERROR.TYPE? ERROR.TYPE is an Excel function that returns a number corresponding to a specific error value. It is commonly used to build conditional logic based on different types of errors, allowing for more precise error handling in complex models.

Business Context & Real-World Use Case

In the fast-paced world of financial analysis, timely and accurate data is paramount. Imagine you're a finance manager responsible for consolidating monthly budget data from various departments. Each department submits its numbers, which you then link to a master budget model using VLOOKUP or XLOOKUP. However, some departments might submit incomplete data, new cost centers might appear, or old ones might be retired. Without robust error handling, your consolidated report quickly becomes a sea of #N/A (missing data) or #REF! (invalid cell references).

Manually sifting through thousands of rows, identifying each error type, and then deciding on the appropriate action (e.g., reaching out to a specific department for missing data, or adjusting a formula for a reference error) is incredibly time-consuming and prone to human error. In my years as a data analyst, I've seen teams waste countless hours on exactly this problem, leading to delayed reports, missed deadlines, and ultimately, poor business decisions based on incomplete information. Automating this process provides immense business value, ensuring data integrity and freeing up valuable analyst time for higher-level strategic tasks. The ERROR.TYPE function is a critical ingredient for building these intelligent, self-correcting financial models. By leveraging ERROR.TYPE, you can program your spreadsheets to react dynamically: perhaps flagging #N/A errors for manual review, while automatically substituting a default value for #DIV/0! errors, significantly streamlining your workflow.

The Ingredients: Understanding ERROR.TYPE's Setup

The ERROR.TYPE function is deceptively simple in its syntax, yet powerful in its application. It takes just one argument, making it easy to integrate into your existing formulas. This function is your specialized error decoder, providing a numerical code for each standard Excel error.

The syntax for the ERROR.TYPE function is as follows:

=ERROR.TYPE(error_val)

Let's break down the single ingredient needed for this powerful recipe:

| Parameter | Description The error_val is the crucial parameter for the ERROR.TYPE function. It specifies the cell reference or expression that potentially contains an Excel error whose type you want to identify. This is the entire 'meal' for the ERROR.TYPE function, the one thing it needs to chew on.

For example, if cell A1 contains an error like #N/A, then =ERROR.TYPE(A1) would return its corresponding number. If B2 contains #DIV/0!, then =ERROR.TYPE(B2) would return a different number. Understanding these numerical codes is key to leveraging ERROR.TYPE effectively.

The Recipe: Step-by-Step Instructions

Let's walk through a practical example where ERROR.TYPE becomes incredibly useful. Suppose you have a list of product IDs and their corresponding prices. You're trying to retrieve the price for a specific product, but sometimes the product ID might not exist, or your lookup range might be invalid, leading to different errors. We'll use the ERROR.TYPE function to identify these issues.

Here's our sample data:

Product ID Price
A101 15.00
B202 25.50
C303 10.20

Let's assume this data is in cells A1:B4 of your worksheet.

Here's how we'll apply the ERROR.TYPE function to diagnose issues in a lookup scenario:

  1. Set Up Your Test Lookups: In cell D2, let's try to look up a valid product.

    • Formula: =VLOOKUP("A101", A:B, 2, FALSE)
    • Result (D2): 15.00

    Next, in cell D3, let's intentionally create an #N/A error by looking up a non-existent product.

    • Formula: =VLOOKUP("X999", A:B, 2, FALSE)
    • Result (D3): #N/A

    Now, in cell D4, let's create a #REF! error by having VLOOKUP reference a non-existent column in the lookup range.

    • Formula: =VLOOKUP("A101", A:B, 3, FALSE) (Note: our range A:B only has 2 columns, so column 3 is invalid.)
    • Result (D4): #REF!

    Finally, in cell D5, let's create a #DIV/0! error as a separate calculation.

    • Formula: =10/0
    • Result (D5): #DIV/0!
  2. Apply the ERROR.TYPE Function: Now, we'll use ERROR.TYPE next to each of our test cells to identify the error codes.

    • For cell D2 (valid value):

      • In cell E2, type: =ERROR.TYPE(D2)
      • Result (E2): #N/A
      • Explanation: ERROR.TYPE returns #N/A because D2 contains a valid number (15.00), not an error. The function only processes actual error values.
    • For cell D3 (#N/A error):

      • In cell E3, type: =ERROR.TYPE(D3)
      • Result (E3): 1
      • Explanation: ERROR.TYPE correctly identifies the #N/A error and returns its specific code, 1. This tells us the lookup value was not found.
    • For cell D4 (#REF! error):

      • In cell E4, type: =ERROR.TYPE(D4)
      • Result (E4): 4
      • Explanation: The function returns 4, indicating a #REF! error, meaning an invalid cell reference occurred within the formula in D4.
    • For cell D5 (#DIV/0! error):

      • In cell E5, type: =ERROR.TYPE(D5)
      • Result (E5): 2
      • Explanation: ERROR.TYPE returns 2, which is the code for a #DIV/0! error, signifying an attempt to divide by zero.

By following these steps, you can see how ERROR.TYPE provides distinct numerical identifiers for each type of error, setting the stage for highly specific error handling in your spreadsheets.

Pro Tips: Level Up Your Skills

Harnessing the full power of ERROR.TYPE goes beyond simply identifying error codes. Experienced Excel users prefer to integrate it into more sophisticated logical constructs to create truly dynamic and resilient spreadsheets.

  1. Build Specific Logic for Different Error Conditions: This is the core strength of ERROR.TYPE. You can use it within an IF statement to perform different actions based on the specific error code. For instance, IF(ERROR.TYPE(D3)=1, "Product Not Found, Check Database", IF(ERROR.TYPE(D3)=4, "Invalid Column Reference, Update Formula", D3)) allows you to provide precise feedback or trigger distinct follow-up actions. Use ERROR.TYPE to build specific logic for different error conditions in a complex model (e.g., only re-lookup if error is #N/A). This ensures your model reacts intelligently to data anomalies.

  2. Combine with CHOOSE for Custom Actions: For models with many potential error types and complex conditional responses, combining ERROR.TYPE with the CHOOSE function can simplify your formula. For example, =CHOOSE(ERROR.TYPE(D3), "No Match", "Div by Zero!", , "Bad Ref") can quickly map error codes to custom messages or functions, creating a cleaner and more manageable formula than nested IF statements.

  3. Distinguish from ISERROR/ISNA: While ISERROR simply checks if any error exists, and ISNA checks specifically for #N/A, ERROR.TYPE provides the granularity to differentiate between all standard Excel errors. This level of detail is crucial when you need to automate error diagnostics and responses without human intervention. Using ERROR.TYPE allows for more surgical error handling compared to broader functions.

Troubleshooting: Common Errors & Fixes

Even a function designed for error identification can sometimes seem to behave unexpectedly. Understanding the common pitfalls when using ERROR.TYPE is key to mastering it.

1. #N/A Error (When error_val is NOT an error)

  • Symptom: You've applied =ERROR.TYPE(CellReference) expecting a numerical code (like 1 or 2), but instead, the ERROR.TYPE function itself returns #N/A.
  • Cause: This is a crucial distinction and a common misunderstanding. ERROR.TYPE is designed to return a number corresponding to an existing Excel error. If the error_val you feed into ERROR.TYPE is not an error (i.e., it's a number, text, a blank cell, or any valid value), ERROR.TYPE will correctly tell you it cannot find an error type by returning #N/A. It's not that ERROR.TYPE is broken; it's indicating that its input is not an error value.
  • Step-by-Step Fix:
    1. Verify the Input: Double-check the cell or expression you're passing as error_val to ERROR.TYPE. Does it genuinely contain an Excel error like #DIV/0!, #VALUE!, #REF!, #N/A (from another function), #NUM!, #NAME?, or #NULL!?
    2. Understand Its Purpose: Remember, ERROR.TYPE identifies which error exists, not if an error exists. If you simply want to know if a cell contains any error, use ISERROR(CellReference). If you want to check if it contains only an #N/A error, use ISNA(CellReference).
    3. Conditional Application: Often, you'll want to use ISERROR first to check if an error is present, and then use ERROR.TYPE to determine its specific type. For example, IF(ISERROR(A1), ERROR.TYPE(A1), "No Error") would prevent ERROR.TYPE from returning #N/A when the cell is fine.

2. #VALUE! Error

  • Symptom: Your ERROR.TYPE formula returns a #VALUE! error.
  • Cause: This typically happens when the error_val argument is not a single error value, a reference to a single cell containing an error, or an expression that evaluates to a single error. For instance, if you pass a range of cells, or a complex array that Excel cannot interpret as a single error.
  • Step-by-Step Fix:
    1. Check error_val Argument: Ensure that error_val refers to a single cell (e.g., A1) or a formula that will resolve to a single error (e.g., VLOOKUP(...) which itself returns an error).
    2. Avoid Ranges: Do not directly feed a range of cells (e.g., A1:A10) into ERROR.TYPE. It expects a singular value. If you need to check a range, consider using array formulas or applying ERROR.TYPE to each cell individually.

3. #NAME? Error

  • Symptom: The ERROR.TYPE function itself displays #NAME?.
  • Cause: This error indicates that Excel doesn't recognize the function name you've entered. Most commonly, it's a simple spelling mistake.
  • Step-by-Step Fix:
    1. Double-Check Spelling: Carefully review your formula and ensure you've typed ERROR.TYPE correctly, without any typos or missing periods. Excel function names must be exact.
    2. Function Availability: While rare for standard functions, ensure you're not trying to use ERROR.TYPE in an older version of Excel where it might not have been available (though it's been around for a very long time).

Quick Reference

For quick recall, here's a concise overview of the ERROR.TYPE function:

  • Syntax: =ERROR.TYPE(error_val)
  • Purpose: Returns a number (1-7) identifying the type of Excel error in error_val. If error_val is not an error, ERROR.TYPE returns #N/A.
  • Error Codes:
    • 1: #N/A
    • 2: #DIV/0!
    • 3: #VALUE!
    • 4: #REF!
    • 5: #NAME?
    • 6: #NUM!
    • 7: #NULL!
  • Most Common Use Case: Building conditional logic (e.g., with IF or CHOOSE) to create specific responses or actions for different types of errors within complex spreadsheet models.

Related Functions

👨‍💻

Written by The Head Chef

Former 10-year Financial Analyst who survived countless month-end closes. I build these recipes to save you from weekend-ruining spreadsheet errors.

Read the full story →

You might also find these useful 💡