Sum or leave blank

Charles_

New Member
Joined
Dec 12, 2012
Messages
32
Hi all,

I am trying to work out a formula that will do a calculation OR don't and leave blank if there is a zero or a blank cell.

Thanks in advance.

Example:

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C (expected result of formula)[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]10[/TD]
[TD]=A1[/TD]
[TD]10[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]18[/TD]
[TD]IF in A2 there is a number that it is not '0' or blank, leave this cell blank. Otherwise =A1+A2[/TD]
[TD]28[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]12[/TD]
[TD]IF in A2 there is a number that it is not '0' or blank, leave this cell blank. Otherwise =A1+A2+A3[/TD]
[TD]40[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]0[/TD]
[TD]IF in A2 there is a number that it is not '0' or blank, leave this cell blank. Otherwise =A1+A2+A3+A4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD]IF in A2 there is a number that it is not '0' or blank, leave this cell blank. Otherwise =A1+A2+A3+A4+A5[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Is this what you want


Excel 2013/2016
ABC
11010
21828
31240
40
5
61151
Anvil Cottage 001
Cell Formulas
RangeFormula
C1=A1
C2=IF(OR(A2={"",0}),"",SUM(A$1:A2))
 
Last edited:
Upvote 0
or in C1 and copy down

Code:
=IF(A1<>0, "", sum($A$1:A1))

Probably faster
it will not sum if you add text
 
Last edited:
Upvote 0
Thank you once again.

I am using the table to feed into a line graph and it picks up the empty cell as '0' rather than nothing. If the cell is left blank, the graph shows it correctly (gap) but with the formula it brings it down to '0'. Is there something that can be added to the formula?
 
Upvote 0
if you place a formula even if shows nothing there is something there

that's why the graph returns 0

in your case i can only think in a macro

if you are you ok with it?
 
Upvote 0
if you are ok with a macro try this

Code:
Sub FillFormula
Dim i as Long, x as Long

i=Cells(Rows.Count, 1).End(xlUp).Row

For x=1 to i
     If Not Cells(x,1)=0 Then Cells(x,3).FormulaR1C1= "=SUM(R1C1:RC[-2])"
Next x
End Sub
 
Upvote 0
if you place a formula even if shows nothing there is something there

that's why the graph returns 0

in your case i can only think in a macro

if you are you ok with it?

Thank you but I can't use a macro in this case, I wonder if I can point the graph to a different range and have a formula there to paste values only, is that possible?
 
Upvote 0

Forum statistics

Threads
1,223,957
Messages
6,175,625
Members
452,661
Latest member
Nonhle

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
Back
Top