Google-sheets – Formula to ignore blank cells and calculate cells having numbers only

google sheets

I am looking for a Formula to calculate cells having numbers only and ignore blank cells.
The condition is between two cells, IF there is a value in A column then ADDITION should take place or IF there is value in B column then SUBTRACTION should take place

Case 1:

A2(number),B2(Empty),C2=(C1+A2) {Ignoring B2 as blank cell} 

Case 2:

A2(Empty),B2(number),C2=(C1-B2) {Ignoring A2 as blank cell}

Kindly suggest appropriate formula to the above condition. Thanks!!

Best Answer

Please try the following formula in cell C2:

=IFNA(IFS(ISNUMBER(A2),C1+A2,ISNUMBER(B2),C1-B2),)

Functions used: