Home > OS >  Inserting Date In Cell Upon Checkbox True
Inserting Date In Cell Upon Checkbox True

Time:06-20

I am having issues making this work. I want to insert todays date in colum 4 upon making checkbox true in colum 1. There are multiple rows. I am not seeing the error of my ways. Any suggestions would be appreciated.

Thanks,

function onEdit(e) {
  var ss = e.source.getActiveSheet();
  var date =  new Date();

  if (e.range.columnStart != 1 || e.value != "TRUE") return;
  ss.getRange(e.range.rowStart,4).setValue(date);
}

CodePudding user response:

Instead of:

E.value != "TRUE"

Simply use:

!e.value

And then instead of:

ss.getRange(e.range.rowStart,4).setValue(date)

You can simply use:

e.range.offset(0,3).setValue(date)

That allows you to eliminate the need for the ss variable as well.

  • Related