Excel Sum Only Numbers Ignore Errors Guide
In this article
To sum a range of cells while ignoring error values, use the AGGREGATE function with the formula =AGGREGATE(9, 6, range). The number 9 tells Excel to perform a SUM, and the number 6 tells it to ignore all error values in the specified range. This prevents your total from returning an error just because one cell in your data set contains a #DIV/0! or #N/A result.
In a standard Excel spreadsheet, the basic SUM function is designed to include every cell in a range. However, if even a single cell in that range contains an error, the SUM function will fail and return that same error. This is a common frustration when dealing with large datasets, VLOOKUPs that occasionally fail, or complex financial models where some divisions result in zeros. By using specialized functions like AGGREGATE or SUMIF, you can create a robust total that remains accurate regardless of the health of the individual cells.
What You'll Need
- A computer with Microsoft Excel installed (Excel 2010 or newer for the AGGREGATE function).
- A dataset containing numbers and at least one error value (such as #VALUE!, #N/A, #REF!, or #DIV/0!).
- Basic knowledge of how to enter a formula into a cell.
Step-by-Step
- Identify your data range: Locate the column or row of numbers you wish to total. For this example, assume your numbers and errors are located in cells A1 through A10.
- Select the target cell: Click on the empty cell where you want the final total to appear.
- Enter the AGGREGATE function: Type the following formula exactly:
=AGGREGATE(9, 6, A1:A10). - Understand the arguments:
- The first argument (9) is the function number. In Excel's AGGREGATE library, 9 represents the SUM function.
- The second argument (6) is the option code. The code 6 specifically instructs Excel to ignore all error values.
- The third argument (A1:A10) is the range of cells you are calculating.
- Press Enter: Once you hit Enter, Excel will scan the range, skip any cells containing errors, and provide the sum of the remaining valid numbers.
- Alternative Method (SUMIF): If you are using a very old version of Excel that does not support AGGREGATE, you can use the SUMIF function. Type
=SUMIF(A1:A10, "<9.99E+307"). This formula tells Excel to sum only the values that are numerically less than the largest possible number Excel can handle, effectively ignoring all non-numeric error codes. - Alternative Method (SUMIFS with Criteria): If you only want to ignore specific errors like #N/A while keeping others, you can use a combination of IFERROR and SUM, though this usually requires creating a helper column. In a helper column, use
=IFERROR(A1, 0)and then sum that helper column.
Common Mistakes
One of the most frequent mistakes is using the standard =SUM() function and expecting it to automatically skip errors. It will not. If cell A5 contains #DIV/0!, =SUM(A1:A10) will always return #DIV/0!. You must use a function specifically designed to handle or ignore errors.
Another common error is entering the wrong option code in the AGGREGATE function. Users often confuse option 6 (ignore error values) with option 5 (ignore hidden rows) or option 7 (ignore hidden rows and error values). If you use option 5, your errors will still trigger a failure in the total. Always ensure the second digit in your AGGREGATE formula is 6 or 7.
Some users attempt to use =SUM(IFERROR(A1:A10, 0)). In older versions of Excel, this is an array formula. If you do not press Ctrl+Shift+Enter after typing it, the formula will not work correctly. While newer versions of Excel (Office 365) handle dynamic arrays automatically, relying on AGGREGATE is generally safer and more efficient across different versions.
Finally, be careful with the range selection. If you accidentally include the cell where your total formula is located within the range (e.g., putting the formula in A11 and summing A1:A11), you will create a circular reference error, which will cause the formula to return 0 or an error message.
Tips
To make your spreadsheet more professional, combine the error-ignoring sum with Conditional Formatting. You can set a rule to highlight all cells containing errors in red. This allows you to see the correct total via the AGGREGATE function while simultaneously identifying which specific data points need to be fixed.
If you are working with a Table (Insert > Table), use structured references instead of cell ranges. For example, =AGGREGATE(9, 6, Table1[Amount]). This ensures that as you add new rows to your table, the sum automatically updates to include the new data without you having to manually change A1:A10 to A1:A11.
For those who need to ignore both errors and hidden rows (which happens often when using filters), change the option code from 6 to 7. The formula =AGGREGATE(9, 7, A1:A10) is incredibly powerful for dashboards because it only sums the visible, error-free numbers currently on your screen.
If your data contains text that you also want to ignore, the AGGREGATE function handles this naturally. Unlike some complex array formulas, AGGREGATE is designed to be a "Swiss Army Knife" for totals, making it the most stable choice for messy datasets.
Troubleshooting
If your AGGREGATE formula is returning #NAME?, check your spelling. Ensure you haven't typed "AGREGATE" with one 'G'. Also, ensure you are not using a version of Excel older than 2010, as the function was not available in Excel 2007 or earlier.
If the formula returns 0 when you know there are numbers present, check the formatting of your numbers. Sometimes numbers are stored as text. If a number is stored as text, Excel may not recognize it as a value to be summed. You can fix this by selecting the range, clicking the small warning icon that appears, and selecting Convert to Number.
If the formula is returning a value that seems too low, check if you have accidentally used option 7 instead of 6. Option 7 ignores hidden rows. If you have filtered your list or manually hidden rows, those values will not be included in the total. Switch back to option 6 to include all error-free cells regardless of visibility.
If you receive a circular reference warning, double-check your range. Ensure the cell containing the formula is outside the range being summed. For example, if your formula is in cell B1, your range should be A1:A10, not B1:B10.
Frequently Asked Questions
Can I use this to ignore #N/A specifically?
Yes, the AGGREGATE function with option 6 ignores all error types, including #N/A, #VALUE!, #REF!, and #DIV/0!. It is a blanket solution for all Excel error codes.
Does this work in Google Sheets?
No, the AGGREGATE function is specific to Microsoft Excel. In Google Sheets, you should use =SUMIF(A1:A10, "<9.99E+307") or =SUM(IFERROR(A1:A10, 0)) wrapped in an ARRAYFORMULA.
Will this ignore cells that are blank?
Yes, both the standard SUM function and the AGGREGATE function ignore blank cells by default. They do not count as errors; they are simply treated as empty.
Can I use this for Average instead of Sum?
Yes. Simply change the first argument from 9 to 1. The formula =AGGREGATE(1, 6, A1:A10) will calculate the average of the range while ignoring all error values.
Is there a way to sum only the errors?
While AGGREGATE ignores errors, you can count them using =SUMPRODUCT(--ISERROR(A1:A10)). However, you cannot "sum" the value of an error because an error, by definition, has no numerical value.
Does the order of the numbers in the range matter?
No, the AGGREGATE function scans the entire specified range regardless of the order of the numbers or where the errors are positioned.