I have a range and need to sum it using SUM function but the result is N/A if there is any N/A value. How can I make the SUM function to treat the N/A value as 0 value? Please help!
7 Answers
Use Array Formula
=SUM(IF(ISNA(A1:A4),0,A1:A4))
Press Ctrl+Shift+Enter after entering the formula
Note: Replace A1:A4 with your range
- 5,002
- 2
- 22
- 39
There is a new function in Excel which will add all the values either positive or negative while ignoring NA's.
=aggregate(9,6, range of your data)
9 is used for sum while 6 is for ignoring all NA's. There are other options, as well, beside addition. For example, you can do product, standard deviation, and so on.
More information on AGGREGATE here.
- 27,486
The easiest way:
Use SUMIF the value > 0.
So the syntax for that one is
=SUMIF(A1:B2, "> 0")
You will get the same result since it will ignore any non-numeric or 0 values.
- 8,306
- 28
- 31
-
2
-
1Could do
=SUMIF(A1:B2, ">=0") + SUMIF(A1:B2, "<0")to include negative numbers. I suspect that would be faster than the accepted array formula solution, if performance is a concern. – kizzx2 Dec 11 '12 at 01:46
You can convert the #N/A to zeros in your source range and then use the normal SUM function:
=IF(ISNA(OriginalFormula), 0, OriginalFormula)
- 16,997
-
2Since office 2007 there's a new feature,
IFERROR, and then it can look like this:=IFERROR(OriginalFormula,0)making it much nicer. – Michael Oct 15 '12 at 10:21 -
If there are formulas I'd copy as numbers, replace #N/A in column with 0 and then sum as usually
- 15
=AVERAGE(IF(ISNA(A1:A4),"",A1:A4))– wilson May 28 '14 at 04:18=aggregate(...)is a more elegant solution for excel 2010 and onwards. btw, i only have office 2010 / 2003 on hand, so i cannot test the array formula in 2013. – wilson Mar 18 '16 at 02:57