0

I am trying to update multiple cells based on input in each. The first works fine with a specific text from dropdown but I get no results on the other remaining 3. Here is the script I have:

function onEdit(e) {
  var sheet = e.source.getActiveSheet()
  if(sheet.getName() !== 'Dec2021' || e.range.columnStart !== 3 || e.range.rowStart < 0) return;
  e.range.offset(0,7).setValue(e.value == '2-Ready' ? new Date() : null)
}

function onEdit(e) {
  var sheet = e.source.getActiveSheet()
  if(sheet.getName() !== 'Dec2021' || e.range.columnStart !== 8 || e.range.rowStart < 0) return;
  e.range.offset(0,9).setValue(typeof e.value == 'object' ? null : new Date())
}

function onEdit(e) {
  var sheet = e.source.getActiveSheet()
  if(sheet.getName() !== 'Dec2021' || e.range.columnStart !== 7 || e.range.rowStart < 0) return;
  e.range.offset(0,9).setValue(typeof e.value == 'object' ? null : new Date())
}

function onEdit(e) {
  var sheet = e.source.getActiveSheet()
  if(sheet.getName() !== 'Dec2021' || e.range.columnStart !== 6 || e.range.rowStart < 0) return;
  e.range.offset(0,9).setValue(typeof e.value == 'object' ? null : new Date())
}
1

1 Answer 1

0

In an Apps Script project, each global function should have a unique name. To make your code work, you will have to combine the functions into one as shown in the onEdit(e) best practices post.

But there are much better ways to implement timestamps. You may want to take a look at scripts such as yetAnotherTimestamp_, timestampMultipleRanges_ and timestampMultipleColumns_.

Also see Apps Script at Stack Overflow.

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