0

I'm trying to apply this script to a specific tab to not ruin all the other tabs.

function onEdit(e) {

  let range=e.range;
  let activeRow = range.getRow();
  let activeColumn = range.getColumn();
  let cellValue = range.getValue();
  let sheet = SpreadsheetApp.getActiveSheet();


    if (activeColumn == 9) {

      if (cellValue == false) {

          sheet.getRange(activeRow,8).clearContent();

      } else {

          sheet.getRange(activeRow,8).setValue(new Date());

      }

    }
  
 }
1

1 Answer 1

1

Use Sheet.getName(), like this:

function onEdit(e) {
  if (e.range.columnStart !== 9
    || e.range.getSheet().getName().match(/^(Sheet1|Sheet2)$/i)) {
    return;
  }
  e.range.offset(0, -1)
    .setValue(e.value === 'FALSE' ? null : new Date());
}

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.