The IFERROR function in Google Sheets is a powerful tool designed to manage and handle errors in formulas smoothly. By providing a mechanism to specify alternative outcomes when an error occurs, it enhances the clarity and usability of your spreadsheets. This function is especially useful for avoiding disruptive error messages like DIV/0! or N/A, allowing users to maintain a clean and professional appearance in their data presentations.
Syntax
IFERROR(value, [value_if_error])
- value: The primary argument that you want to evaluate for errors.
- value_if_error: The outcome to return if the first argument results in an error; this parameter is optional.
Example #1
=IFERROR(A1/B1, "Error in division")
This formula checks if dividing A1 by B1 results in an error. If it does, instead of displaying an error message, it returns “Error in division”. For instance, if A1 contains 10 and B1 is 0, the output will be “Error in division”.
Example #2
=IFERROR(VLOOKUP(C1, D1:E10, 2, FALSE), "Not found")
In this case, the function searches for a value in C1 within the range D1:E10. If it cannot find the value, it returns “Not found” instead of an error. For example, if C1 is 15 and it does not exist in D1:E10, the output will be “Not found”.
Example #3
=IFERROR(CONCATENATE(A1, B1), "Concatenation error")
Here, if concatenating A1 and B1 encounters any issue (such as one of the cells being an invalid data type), instead of an error, it will return “Concatenation error”. For instance, if A1 is “Hello” and B1 is an array or text that causes an error, the output will be “Concatenation error”.
Error handling
Common error messages that IFERROR handles include:- DIV/0! – This occurs when a number is divided by zero. IFERROR can return a user-friendly message instead.
- N/A – This indicates that a value is not available to the function, such as when a lookup doesn’t find a match.
- VALUE! – This error arises when the wrong type of argument is provided to a function. IFERROR will replace it with the specified output.