IFERROR Function in Excel

Part 1. Introduce:
🔹 Definition: The IFERROR function in Microsoft Excel handles errors that might occur in formulas. It allows you to specify a custom value or message that should be displayed when a formula evaluates to an error. This Function helps to improve the readability of your spreadsheets and prevents error messages from being shown to users.

🔹 Purpose: The primary purpose of the IFERROR function is to handle errors in formulas and provide a more user-friendly output when errors occur. Instead of displaying error codes like #N/A, #VALUE!, #DIV/0!, etc., you can display a custom message of your choice.

🔹 Syntax & Arguments: The syntax of the IFERROR function is as follows:

syntax
IFERROR(value, value_if_error)
  • value: This is the expression or formula that you want to evaluate.
  • value_if_error: This is the value or message displayed if the value argument results in an error.

🔹 Explain the Arguments in the Function:

  • The value The argument represents the formula or expression you want to evaluate for errors. If this argument results in a mistake, the Function will return the value specified in the value_if_error argument.
  • The value_if_error argument is the value or message you want to display when the value argument results in an error.

🔹 Return Value: The IFERROR function returns the result of the value argument if it does not result in an error. If the value argument evaluates to an error, the Function returns the value specified in the value_if_error argument.

🔹 Remarks:

  • The IFERROR function is commonly used with other parts that may produce errors, such as VLOOKUP, INDEX-MATCH, SUMIF, AVERAGE, etc.
  • It is essential to handle errors in formulas to ensure the accuracy and reliability of your Excel spreadsheets.

Part 2. Examples:

🔹 Example 1: Handling #N/A Error in VLOOKUP

ABC
2Apple10=IFERROR(VLOOKUP(“Apple”, A2:B4, 2, FALSE), “Not Found”)
3Banana8=IFERROR(VLOOKUP(“Banana”, A2:B4, 2, FALSE), “Not Found”)
4Orange12=IFERROR(VLOOKUP(“Grapes”, A2:B4, 2, FALSE), “Not Found”)

Explanation: In this example, we use the VLOOKUP function to search for the names of fruits in column A. The corresponding quantity in column B is displayed if the fruit is found. However, if the fruit is not found (resulting in a #N/A error), the message “Not Found” is displayed.

🔹 Example 2: Handling #DIV/0! Error with AVERAGE function

ABC
2100=IFERROR(AVERAGE(A2:B4), “Invalid Values”)
384=IFERROR(AVERAGE(A3:B4), “Invalid Values”)
4123=IFERROR(AVERAGE(A4:B4), “Invalid Values”)

Explanation: In this example, we use the AVERAGE Function to calculate the average values in each row. If any cell in the range contains a zero (resulting in a #DIV/0! error), the message “Invalid Values” is displayed.

🔹 Example 3: Handling #VALUE! Error with the SUM function

ABC
21020=IFERROR(SUM(A2:B4), “Invalid Values”)
330“abc”=IFERROR(SUM(A3:B4), “Invalid Values”)
44050=IFERROR(SUM(A4:B4), “Invalid Values”)

Explanation: In this example, we use the SUM function to add values in each row. If any cell in the range contains a non-numeric value (resulting in a #VALUE! error), the message “Invalid Values” is displayed.

🔹 Example 4: Handling #NUM! Error in Mathematical Calculation

ABC
21020=IFERROR(A2/B2, “Error: Division by Zero”)
3150=IFERROR(A3/B3, “Error: Division by Zero”)
4305=IFERROR(A4/B4, “Error: Division by Zero”)

Explanation: We use a simple division operation with the IFERROR function in this example. If the denominator in column B is zero (resulting in a #DIV/0! error), the message “Error: Division by Zero” is displayed.

🔹 Example 5: Handling #NAME? Error in Function Name

ABC
2105=IFERROR(SUM(A2:B2), “Error: Invalid Function”)
3158=IFERROR(AVERAGE(A3:B3), “Error: Invalid Function”)
42012=IFERROR(MAX(A4:B4), “Error: Invalid Function”)

Explanation: In this example, we use various functions like SUM, AVERAGE, and MAX. If any function name is misspelled or not recognized (resulting in a #NAME? error), the message “Error: Invalid Function” is displayed.

🔹 Example 6: Handling #REF! Error in Cell Reference

ABC
2510=IFERROR(A2+B3, “Error: Invalid Cell Reference”)
3815=IFERROR(A3+C4, “Error: Invalid Cell Reference”)
41220=IFERROR(B4+C5, “Error: Invalid Cell Reference”)

Explanation: In this example, we use cell references in formulas. If any cell reference is invalid (resulting in a #REF! error), the message “Error: Invalid Cell Reference” is displayed.

🔹 Example 7: Handling #NULL! Error in Intersection of Ranges

ABC
212=IFERROR(SUM(A2:B2 C2), “Error: Invalid Range”)
334=IFERROR(SUM(A3:B3 D3), “Error: Invalid Range”)
456=IFERROR(AVERAGE(A4:B4 E4), “Error: Invalid Range”)

Explanation: In this example, we use the SUM and AVERAGE functions with ranges that do not intersect correctly (resulting in a #NULL! error). The message “Error: Invalid Range” is displayed when such an error occurs.

🔹 Example 8: Handling #VALUE! Error with TEXT Function

ABC
2Apple5=IFERROR(TEXT(A2, B2), “Error: Invalid Format”)
3Banana“abc”=IFERROR(TEXT(A3, B3), “Error: Invalid Format”)
4Orange10=IFERROR(TEXT(A4, B4), “Error: Invalid Format”)

Explanation: In this example, we use the TEXT function to format the values in column A based on the format code in column B. If the format code is invalid (resulting in a #VALUE! error), the “Error: Invalid Format” message is displayed.

🔹 Example 9: Handling #NUM! Error with POWER Function

ABC
232=IFERROR(POWER(A2, B2), “Error: Invalid Power”)
3-40.5=IFERROR(POWER(A3, B3), “Error: Invalid Power”)
45-2=IFERROR(POWER(A4, B4), “Error: Invalid Power”)

Explanation: In this example, we use the POWER function to calculate the power of values in column A based on the exponent in column B. If the exponent results in a non-numeric value (resulting in a #NUM! error), the message “Error: Invalid Power” is displayed.

🔹 Example 10: Handling #DIV/0! Error with IF Function

ABC
2102=IFERROR(IF(B2<>0, A2/B2, “Divide by Zero”), “Error: Division by Zero”)
3150=IFERROR(IF(B3<>0, A3/B3, “Divide by Zero”), “Error: Division by Zero”)
4204=IFERROR(IF(B4<>0, A4/B4, “Divide by Zero”), “Error: Division by Zero”)

Explanation: In this example, we use the IF function to check if the denominator in column B is zero. The division is performed without zero; otherwise, the message “Divide by Zero” is displayed.

🔹 Example 11: Handling #NAME? Error with CONCATENATE Function

ABC
2JohnDoe=IFERROR(CONCATENATE(A2, B2), “Error: Invalid Function”)
3Jane“Smith”=IFERROR(CONCATENATE(A3, B3), “Error: Invalid Function”)
4“Alice”“Wonderland”=IFERROR(CONCATENATE(A4, B4), “Error: Invalid Function”)

Explanation: In this example, we use the CONCATENATE function to combine the values in columns A and B. If any value is not recognized (resulting in a #NAME? error), the message “Error: Invalid Function” is displayed.

🔹 Example 12: Handling #NULL! Error with INDEX-MATCH Function

ABC
2Apple10=IFERROR(INDEX(A2:A4, MATCH(“Banana”, B2:B4, 0)), “Not Found”)
3Banana8=IFERROR(INDEX(A2:A4, MATCH(“Orange”, B2:B4, 0)), “Not Found”)
4Orange12=IFERROR(INDEX(A2:A4, MATCH(“Grapes”, B2:B4, 0)), “Not Found”)

Explanation: In this example, we use the INDEX-MATCH function combination to find the fruit names in column A based on the quantities in column B. If the fruit is not found (resulting in a #NULL! error), the message “Not Found” is displayed.

Part 3. Tips and Tricks:

  • The IFERROR function is an essential tool to handle errors and improve the user experience in Excel spreadsheets.
  • Combine the IFERROR function with other functions to make your formulas more robust and error-resistant.
  • Use descriptive and user-friendly messages in the value_if_error argument to communicate the error to users effectively.