Google-sheets – How to apply “sendAlertEmailWhenCellValueIsNotEmpty” script to multiple tabs in Google Sheets

google sheetsgoogle-apps-script

I would like to apply this to let's say "Weekly" and "Monthly" tab.
Here's my script:

function sendAlertEmailWhenCellValueIsNotEmpty(){
  //send an email alert when cellToWatch is not empty
  //set this function to run through a time driven trigger
  //choose resource> Current project's triggers> Add a new trigger>Time-driven>Day Timer
  //see https://productforums.google/d/topic/docs/39Ysmg7nAjk/discussion

  //edit the following variable to fit your needs
  var cellToWatch="DAILY!W12";
  var mailAddress="someone@gmail.com";
  var emailSubject="Spreadsheet alert:BECKMAN COULTER UNICEL DXI800 MISSING DAILY MAINTENANCE";
      var emailBody="This is an email alert from your google spreadsheet:BECKMAN COULTER UNICEL DXI800 MISSING DAILY MAINTENANCE" 

  if(SpreadsheetApp.getActiveSpreadsheet().getRange(cellToWatch).getValue()!=""){
    MailApp.sendEmail(emailAddress,emailSubject,emailBody);
  }
}

Best Answer

In the script it is mentioned:

//edit the following variable to fit your needs
  var cellToWatch="DAILY!W12";
  var mailAddress="someone@gmail.com";
  var emailSubject="Spreadsheet alert:BECKMAN COULTER UNICEL DXI800 MISSING DAILY MAINTENANCE";
      var emailBody="This is an email alert from your google spreadsheet:BECKMAN COULTER UNICEL DXI800 MISSING DAILY MAINTENANCE" 
  • The variable vardefined in cellToWatch="DAILY!W12" refers to cell W12 on sheet DAILY
  • mailAddress="someone@gmail.com" mentions who the email will be sent to
  • emailSubject="Spreadsheet alert:BECKMAN .... is the Subject of the email
  • emailBody="This is an email.... is the body of the email.

Play around with these variables and see what you get.

And please start reading about scripting.