![](/img/trans.png)
[英]Writing data to master Google Spreadsheet from multiple other sheets; am overwriting results of each feeder sheet instead of getting all results
[英]Google Spreadsheet function gets data from all sheets instead of just one
這是我編寫的功能,每當編輯指定的單元格/行/列時,它都會發送電子郵件通知某人,並且我將其設置為觸發onEdit。 它按原樣工作。
/* 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 = "me@email.com";
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
}
}
我的問題是,只有在編輯電子表格的某個工作表(頁面)上的列或行時,而不是電子表格中任何工作表的X列時,我才需要使用此選項。
有任何想法嗎? 我希望我錯過了一些簡單的事情,但是我一直找不到解決方案。
您可以在分配工作sheet
變量后中斷該函數:
if (sheet.getSheetName() != 'SheetIWant') return;
您需要查看onEdit提供的參數。 它會告訴您更改發生的位置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.