Search code examples
if-statementgoogle-sheetsgoogle-sheets-formulaarray-formulascumulative-sum

Subtracting value over multiple cells


I am trying to build a spreadsheet that keeps track of my inventory. I want to use the First In First Out approach and need the formula to solve the following problem. I want to subtract the value 16 from the list of stocks over multiple rows.

Value= 16

Column A    -->   Column B
  10                 0
  5                  0
  2                  1
  3                  3
  12                12

Solution

  • Sample below:

    • Subtract: B2 = number [16]
    • Subtract: B3 = formula =B2-A2. Copy down.
    • Out: C2 = formula =IF(B2>A2,0,IF(B2>0,A2-B2,A2)). Copy down.

    enter image description here