I have 3 columns in a Google Docs spreadsheet: A) Inventory purchased price, B) Inventory sold price, C) Difference between A and B (i.e. profit or loss)

Data is going to be entered manually into columns A and B. How do I make column C to 1) display the calculated amount for each row, and 2) color profitable sales in green and unprofitable in red?

  • For 2, you want "conditional formatting". There are already several questions here on that topic; just do a search.
    – ale
    Commented Apr 11, 2015 at 11:21

1 Answer 1


.. and for the first question, assuming your data start in row 2, in C2 try:

=ArrayFormula(if(len(A2:A)*len(B2:B), B2:B-A2:A,))

This formula should automaticcaly output the difference between B and A when data is entered. See if that works ?

  • It worked fantastically. Thank you very much!
    – Matthew S
    Commented Apr 11, 2015 at 16:38
  • How would I do it if all numbers are in one single column and I want to calculate the difference between the current row and the row above? Like =A2-A1 and make this continue down "forever". Commented May 19, 2020 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.