0

I have an onEdit script that has previously been working fine to put a timestamp in a cell based on edits of a certain cell in the same row. Up until about two days ago, the runtime was about a second, maximum, usually within the 0.2-0.3 seconds range. In the last two days, it has been timing out at 30 seconds. I made no changes to the script itself, although I have been making some changes to the rest of the workbook (but nothing that I feel should interrupt the script?). Script included below-- can I make any changes to make this work, or is there anything that could be in my book that is affecting the script's functionality?

function onEdit(e) {

  var row = e.range.getRow();
  var col = e.range.getColumn();

  if(e.source.getActiveSheet().getName() === "OEEMG" && col === 14 && row > 3){
    e.source.getActiveSheet().getRange(row, 16).setValue(new Date ());

  }

  else if(e.source.getActiveSheet().getName() === "OEOL" && col === 14 && row > 3){
    e.source.getActiveSheet().getRange(row, 16).setValue(new Date ());

  }

  else if(e.source.getActiveSheet().getName() === "AALDV" && col === 8 && row > 3){
    e.source.getActiveSheet().getRange(row, 16).setValue(new Date ());

  }

  else if(e.source.getActiveSheet().getName() === "AdInq" && col === 12 && row > 3){
    e.source.getActiveSheet().getRange(row, 18).setValue(new Date ());

  }

}

Thanks in advance!

3
  • 1
    Welcome to Web Applications Try changing e.source.getActiveSheet() by e.range.getSheet(), once said that, troublehshooting like questions are off-topic on this site... consider to post a question on Stack Overflow but bear in mind that it's very likely that you will be required to add a "mcv", meaning that you should try first to reproduce the problem and add all the details necesary for others to reproduce the same problem.
    – Rubén
    Oct 28, 2022 at 16:23
  • Related: webapps.stackexchange.com/q/106809/88163
    – Rubén
    Oct 28, 2022 at 16:39
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Oct 28, 2022 at 23:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.