Let's say that I have two cells A1 (time needed) and B1 (time spent).

I want that when I enter a value in B1 the value of A1 will be reduced automatically.

I want that in some way I could enter in A1 the following formula: =A1-B1

Is it possible in Google Spreadsheets?


As Google Sheets does not natively support iteration with circular referencing, you will need to resort to Google Apps Script. Eg:

function onEdit(e)
  var editRange = e.range;
  var sheet = editRange.getSheet();
  if (sheet.getName() == "Sheet1" && editRange.getA1Notation() == "B1")
    var updateRange = sheet.getRange("A1");
    var newValue = updateRange.getValue() - e.value;
  • Hi Adam, Could you please explain how to use a function in a sheet? i've saved it in the script editor. But I don't know how to let it know that it has to run on those cells. By the way the debug prompt an error about the e parameter. How should I treat it? – GianlucaR Sep 30 '14 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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