For ignoring any type of calculation error, it is better to use exception handling. MS Excel provides an ISERROR function for this purpose. This function is categorized under Information functions. This article will share the complete idea of how the RIGHT function works in Excel independently and then with other Excel functions.
Download the Practice Workbook
ISERROR Function in Excel (Quick View)
Excel ISERROR Function: Syntax & Arguments
Summary
This function indicates any error value (#N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, or #NULL!).
Syntax
=ISERROR (value)
Arguments
Argument | Required or Optional | Value |
---|---|---|
value | Required | Pass the value to check for any error. |
Note:Â
- In the argument, value is provided as a cell address, but we can use it to trap errors inside more complex formulas as well.
- This ISERROR function is available on Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000.
How to Use the ISERROR Function in Excel (5 Examples)
Example 1: Finding Error Using ISERROR Function
Let’s have a product dataset with their ID, Name, Total Price, and Quantity. Now we find Unit Price for each price we will divide the total price by quantity. Here some of the cells of the quantity are missing or the value is 0 which will give #DIV/0! Now the task is to find those error-contained cells using the ISERROR function.
Step 1: Enter the formula in cell G4 and copy it down up to G15
=ISERROR(F4)
Example 2: Calculating Total Error Using SUMPRODUCT and ISERROR Function
Now let’s count the total error that we have found in the first example. For this, we need to use the SUMPRODUCT function additionally.
Step 1: Enter the formula in cell D19 and then press Enter
=SUMPRODUCT(--ISERROR(F4:F15))
Formula Explanation
- Here –ISERROR(F4:F15) this part gives a result array as we have used double unary (—). The value of this will be like this {0,0,0,1,0,0,0,1,0,0,0,1}
- Then the SUMPRODUCT function calculates the total number of True of 1 which will give 3 as we have only three two values or three 1. If you want to explore more about this SUMPRODUCT function we can visit this link
Example 3: Printing Optional Messages for Cells Containing Errors
Instead of showing the error messages, we can show any message on the Unit Price cell using another additional function named IF. So, we will print a message “Quantity not Found” if the quantity is 0 instead of #DIV/0! Error.
Step 1: Enter the formula in cell G4 and copy it down up to G15
=IF(ISERROR(D4/E4),"Quantity not Found",D4/E4)
Formula Explanation
- ISERROR(D4/E4) this is the logical test of the IF function. It will return True or False as output.
- “Quantity not Found” will be printed if the logical test value is True. And the logical test will be true if the ISERROR function finds #DIV/0! Error.
- D4/E4 will be printed if the logical test value is False. That’s means there will be no error and the unit price will be calculated.
- If you want to explore more the IF function you can check this link
Example 4: Control Search Operation Using ISERROR Function
Now we will see how to search for anything and how to handle if there is a search item that is missing or not found in a particular dataset. We will search food names using their ID and show a message if the given input is not available on the dataset.
Step 1: Enter the formula in cell D18 and then press Enter
= IF( ISERROR( VLOOKUP( D18, CHOOSE( {1,2}, $B$4:$B$15, $C$4:$C$15 ), 2, 0) ), “Not available”, VLOOKUP( D18, CHOOSE( {1,2}, $B$4:$B$15, $C$4:$C$15 ), 2, 0) )
Formula Explanation
- CHOOSE( {1,2}, $B$4:$B$15, $C$4:$C$15 ) this will return an array which will contain ID and Name
{1122,” Apples”; 1133, “Eggplant”; 1144, “White Potato ”; 1155, “Mango”; 1166, “Butter”; 1177, “Milk”; 1188, “Cheese”; 2200,” Orange”; 2211,” Pineapple; 2222, ”Cauliflower”; 2233,” Pineapple”} - VLOOKUP( D18, CHOOSE( {1,2}, $B$4:$B$15, $C$4:$C$15 ), 2, 0) ) will then look for D18 in the array and return its 2nd column value.
- ISERROR( VLOOKUP( D18, CHOOSE(..) ) will check if there is an error in function and return TRUE or FALSE.
- IF (ISERROR( VLOOKUP( D18, CHOOSE(..) ), “Not available”, VLOOKUP( D18, CHOOSE() )) will return the corresponding name of the student if present else it will return “Not available.”
Example 5: ISERROR Function in VBA Code
Let’s see how we can detect any error contained in the cell using the button. There will be a code behind the button.
Step 1: Right Click on the button and Assign Macros
Step 2: Click on the New button
Step 3: Now write the code in the window
Code:
Sub Button1_Click()
   'Display IsError function for cell B4 on Sheet6
   MsgBox IsError(Sheet6.Range("B4")), vbOKOnly, "Check Error"
End Sub
Step 3: Now save the code and run it (Shortcut F5)
Step 4: Now type any number divided by 0 and click on the button to check the output
Things to Remember
- This function tests for #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, and #NULL! Errors.
- It returns logical values, TRUE or FALSE.
- ISERROR function in Excel only checks if any given expression returns an error.
Conclusion
That’s it all about the ISERROR function. Here I have tried to give a summary of this function and its different applications. I have shown multiple methods with their respective examples but there can be many other iterations depending on numerous situations. If you have any inquiries or feedback, please let us know in the comment section.
Further Readings
- How to Use ISLOGICAL Function in Excel (4 Examples)
- How to Use ISTEXT Function in Excel (3 Examples)
- How to use ISNA function in Excel (4 Examples)
- How to Use ISEVEN Function in Excel (2 Examples)
- How to Use ISODD Function in Excel (With 4 Examples)
- How to Use ISNUMBER Function in Excel (7 Examples)
- How to Use ISBLANK Function in Excel (2 Examples)