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());

      }

    }
  
 }
New contributor
Dark is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1

1 Answer 1

0

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

Dark is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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