0
votes

This is the function I have written, which sends an email to notify someone whenever a specified cell/row/column is edited, and I have it set to trigger onEdit. It works as is.

/* This function send an email when a specified range is edited
 * The spreadsheets triggers must be set to onEdit for the function
*/

function sendNotification() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sheet = ss.getActiveSheet();
  //Get Active cell
      var mycell = ss.getActiveSelection();
      var cellcol = mycell.getColumn();
      var cellrow = mycell.getRow();
  //Define Notification Details
      var recipients = "[email protected]";
      var subject = "Update to "+ss.getName();
      var body = ss.getName() + "has been updated.  Visit " + ss.getUrl() + " to view the changes.";
  //Check to see if column is A or B to trigger
      if (cellcol == 1, 2)
      {
  //check for row to trigger
        if (cellrow == 1)
        {
  //Send the Email
      MailApp.sendEmail(recipients, subject, body);
      }
  //End sendNotification
 }
}

My issue is that I need this to work only when a column or row on a certain sheet(page) of the spreadsheet is edited, rather than column X in any of the sheets within the spreadsheet.

Any ideas? I'm hoping it's something simple that I missed, but I have been unable to find a solution.

2

2 Answers

1
votes

You could interrupt the function after assigning the sheet variable:

if (sheet.getSheetName() != 'SheetIWant') return;
0
votes

You need to look at the parameters that onEdit provides. It will tell you where the change happened.