SUM function with an IF statement???

grogzy

New Member
Joined
Jul 9, 2008
Messages
12
Please help, as i've been having loadsa trouble with the following....

I have a cell range which needs to be added up, but if all cells in the renge contain "n/a" then i'd like to display that instead.....can this be done????

thanks in advance!!! :)
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,124
Question is a little vague but do you mean something like this ?

=IF(COUNT(A1:A10)=0,"N/A",SUM(A1:A10))
 
Upvote 0

grogzy

New Member
Joined
Jul 9, 2008
Messages
12
YES!!! this is exactly what i was trying to do......thanks lasw10

But now in another cell i need to find the average of the output figure (or if the output is "n/a", then this should be displayed....

can this be done?
 
Upvote 0

Stormseed

Banned
Joined
Sep 18, 2006
Messages
3,274
Please help, as i've been having loadsa trouble with the following....

I have a cell range which needs to be added up, but if all cells in the renge contain "n/a" then i'd like to display that instead.....can this be done????

thanks in advance!!! :)

What if any of the cells contain #N/A and not the whole range ?

Assuming the range A1:A8, perhaps,

PHP:
=IF(COUNTIF(A2:A8,"#N/A"),"#N/A",SUM(A2:A8))
 
Upvote 0

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,124
well assuming the prior formula was returned in say cell B1 you could just use the following in average cell:

=IF($B$1="N/A","N/A",$B$1/COUNT($A$1:$A$10))
 
Upvote 0

Stormseed

Banned
Joined
Sep 18, 2006
Messages
3,274
try,

Confirm the formula with Ctrl+Shift+Enter and not just Enter:
PHP:
=AVERAGE(IF(A1:A10<>0,A1:A10))
 
Upvote 0

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,124
stormseed, you wouldn't need the test of 0, the following (as array) would also work.

=AVERAGE(IF(A1:A10,A1:A10))
 
Upvote 0

Stormseed

Banned
Joined
Sep 18, 2006
Messages
3,274
well assuming the prior formula was returned in say cell B1 you could just use the following in average cell:

=IF($B$1="N/A","N/A",$B$1/COUNT($A$1:$A$10))

Ok, I never thought about that ! you worked out the next formula considering upon the adjacent cell's output value. Your solution is always precise and clear, Luke. I guess, I have to learn a lot from you as well :p
 
Upvote 0

Forum statistics

Threads
1,191,117
Messages
5,984,739
Members
439,906
Latest member
Sekiro1899

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top