I'm new to coding and google app scripts. I write a onEdit script, and when I run it, it shows me. "Start running", and 1 second later "Finished". It doesn't show me any error. How do I make it keep running? This is my script:

function onEdit() {
  var s = SpreadsheetApp.getActiveSpreadsheet();
  var r = s.getActiveCell();
  if (s.getName="Reading Log" && r.getColumn() !=2) {
    r.offset(0,-1).setValue(new Date()).setNumberFormat("MM/dd/yy")

What I want to do is that I have a google sheet reading log. On sheet 'Reading Log' column 2, I'm going to put the name of book or article I read. I want the script automatically fill in the date I enter the name into column 1 next to it. I'll be happy if someone could help me fix it or write a better script. Thank you!


1 Answer 1


The onEdit(e) function is a simple trigger. Do not run the code in the script editor. It runs automatically when you manually edit the spreadsheet.

To insert a timestamp when column B is edited, fix line 4 like this:

  if (s.getName() === 'Reading Log' && r.getColumn() === 2) {

For better performance, use the event object. See onEdit(e) best practices.


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.