What is IFERROR in MS Excel?
The IFERROR function in Microsoft Excel is a powerful tool used to handle errors or calculations that might return an error value, such as #N/A, #DIV/0!, or #VALUE!. This function checks for an error and returns a specified value if an error occurs. It’s helpful when you want your spreadsheet to display meaningful results instead of Excel’s default error messages. Here’s how to use it:
Syntax:
=IFERROR(value, [error_value])
‘value’ is the expression or calculation that could potentially return an error value.
‘error_value’ is the value you want Excel to display if an error occurs.
Example:
Suppose you’re trying to calculate the square root of a cell containing data, but there might be instances when the input is empty or contains text, leading to an error message. In this case, you can use IFERROR with the ISBLANK and ISERROR functions as follows:
=IFERROR(SQRT(A1), "N/A")
In this example, Excel checks if cell A1 is blank using ISBLANK and returns the specified value “N/A” if true. If A1 contains a valid number, the square root will be calculated, and no error message will appear.
You can also apply IFERROR Function to handle division by zero errors:
=IFERROR(B2/C2, "Error: Division by Zero")
Here, B2 is the dividend, C2 is the divisor, and Excel returns the error message “Error: Division by Zero” if C2 is empty or zero. Otherwise, the result of the division will be displayed.
By using IFERROR to handle errors in your Excel spreadsheets, you can ensure that your calculations provide meaningful results without any distracting error messages.