Reputation: 33
I have a spreadsheet in Google Sheets where the master tab has all information (manual input) then =filter
is used to filter data accordingly throughout 12 tabs. Each tab corresponds to a different email address.
How can each email address receive an email when a row is added on their tab? I do have a script as a general email but not good to me on this occasion as it would email whoever I wanted when something has changed and I want only by tabs.
Many thanks in advance
Upvotes: 0
Views: 64
Reputation: 2004
You need to set up a Trigger to listen when the row is inserted.
With the onEdit()
function you can then get the range of the cells that where edited.
See: Event Objects
Example of the onEdit()
function:
function onEdit(e){
// Set a comment on the edited cell to indicate when it was changed.
var range = e.range;
range.setNote('Last modified: ' + new Date());
}
With this range you can now get the sheet of that range with getSheet()
and with that you can do getSheetName()
and you will have done it, you have the name of the modified sheet.
Example of getSheetName()
function:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
Logger.log(sheet.getSheetName());
Finally, you just need to send the email to the address that getSheetName()
returned.
Upvotes: 1