You are learning Error Handling in MS Excel
How to use the SUMIF function with error handling to ignore errors?
There are two common ways to use the SUMIF function with error handling to ignore errors in Excel:
1. Using the IFERROR function:
This method incorporates the IFERROR function within the SUMIF function itself. Here's the syntax:
```excel
=SUMIF(range, criteria, IFERROR(lookup_range,0))
```
- range: The cell range containing the data you want to sum.
- criteria: The criteria you want to match against the range.
- lookup_range: The cell range containing the values to be summed (corresponding to the matching criteria).
- IFERROR(lookup_range,0): This part checks for errors in the lookup_range. If an error occurs, it replaces it with 0 (you can replace 0 with another value if needed).
2. Using SUMIFS with SUMPRODUCT and ISNUMBER:
This method utilizes a combination of SUMIFS, SUMPRODUCT, and ISNUMBER functions. It's slightly more complex but can be useful for advanced scenarios. Here's the syntax:
```excel
=SUMPRODUCT(ISNUMBER(lookup_range)*lookup_range*(range=criteria))
```
- lookup_range: The cell range containing the values to be summed.
- range: The cell range containing the data you want to sum.
- criteria: The criteria you want to match against the range.
- ISNUMBER(lookup_range): This checks if each value in the lookup_range is a number. It returns TRUE for numbers and FALSE for errors.
- lookup_range*(range=criteria): This multiplies the corresponding values in the lookup_range by 1 only if the criteria match in the range. Values with errors will be multiplied by 0 due to the ISNUMBER check, effectively ignoring them.
- SUMPRODUCT: This function sums the resulting product of the two conditions.
Both methods achieve the same result: summing values in the lookup_range that meet the criteria in the range, while ignoring any errors encountered. Choose the method that best suits your needs and comfort level.