In Google Sheets, I am wanting to do something like the following:
If B129=I3, then D129 = 1. 1 now is to be held and never forgotten.
Then, if B129=I3 again, then D129 = 2. D129 can now repetitively increase by 1 over and over again as many times as B129=I3.
Thanks to a wonderful member here, I now have a framework for how this can possibly be done. But I am getting an error message that says: TypeError: Cannot read property "range" from undefined. (line 3, file "Code"), using the code down below?
Because of this error, the problem that I am having is that the code does not run on the spreadsheet at all. Nothing happens, even if I were to perform what I need to do on the actual spreadsheet, because the error continues to come up as: Cannot read property "range" from undefined. (Line 3, file code).
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("M Numbers");
if (e.range.getA1Notation() != 'B129') return; //Something other than the cell you wanted changed
var x = ss.getRange("I3").getValue();
if (e.getValue() != x) return; //B129 doesn't equal I3
var counter = ss.getRange("D129"); // cell reference
counter.setValue(counter.getValue() + 1);
}
This
onEdit(e)script is using Event Objects. You can't run these scripts manually, they run automatically when the spreadsheet is edited.e.rangeis where you're trying to call the event object to get the edited range of the sheet. Since there's no edited range to pull when you run it manually in script editor, it'll fail with the error you're experiencing.