2

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?

0

1 Answer 1

1

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;
    updateRange.setValue(newValue);
  }
}
1
  • 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
    Commented Sep 30, 2014 at 10:55

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.