1
votes

So, I'm currently working with this thread. The solution there works, but I still have a problem as I need to execute the script in several sheets with a similar sheet name. By similar sheet name, means I most likely have 10 sheets with a name which includes "SF2". I tried to modify the code with this thread, but I can't make it work.

The following is the code that works on one sheet:

function onEdit(e) {
  let sheet = e.range.getSheet();
  let r = e.range.getValue();
  if (sheet.getName() == "SEPT-School Form 2 (SF2)" && r == "t") {
    let col = e.range.getColumn();
    let row = e.range.getRow();
    sheet.getRange(13,40).copyTo(sheet.getRange(row,col));
  }
}
1

1 Answers

1
votes

Explanation:

You can simply use includes to check whether the sheet name includes the word SF2.

Solution:

function onEdit(e) {
  let sheet = e.range.getSheet();
  let r = e.range.getValue();
  if (sheet.getName().includes("SF2") && r == "t") {
    let col = e.range.getColumn();
    let row = e.range.getRow();
    sheet.getRange(13,40).copyTo(sheet.getRange(row,col));
  }
}