Home > database >  Google Apps Script OnEdit only works on one specific cell, help please
Google Apps Script OnEdit only works on one specific cell, help please

Time:05-27

I got this work once the way I wanted but then I changed the code etc. and it didn't work anymore. But anyway here is my problem:

So I would like to have this A1Notation work on cells C3:C28. The code will only work if I remove the "C28" and run the code only in "C3". Here is the code:

    function onEdit(e) {
      if (e.range.getSheet().getName()   '!'   e.range.getA1Notation() === 'Sheet1!C3:C28') {
        mycode()
      }

}

So everything else working just fine but I can't get the range list correct. Thank you for advance!

CodePudding user response:

Try

function onEdit(e) {

  if (e.source.getActiveSheet().getName() === `Sheet1`) {

    if (
      e.range.rowStart >= 3 && e.range.rowEnd <= 28 &&
      e.range.columnStart === 3 && e.range.columnEnd === 3
    ) {

      // Code

    }

  }

}

Although this does not use A1 notation, this will only run onEdit on Sheet1 in the range of C3:C28.

  • Related