Answer the question
In order to leave comments, you need to log in
How to fire a trigger when editing a specific cell, specific sheet?
Hello, this issue has already been discussed on the forum. But I still don't understand how it works. I need the trigger to run when cell "M2" "Sheet1" is edited and fire this trigger:
function CopyList() {
var sss = SpreadsheetApp.openById('ID-ТАБЛИЦЫ1');
var ss = sss.getSheetByName('Sheet1');
var from = ss;
var fromValues = from.getDataRange().getValues();
var fromData = fromValues
var tss = SpreadsheetApp.openById('ID-ТАБЛИЦЫ2');
var ts = tss.getSheetByName('Sheet2');
ts.getRange(ts.getLastRow() + 1, 1, fromData.length, fromData[0].length)
.setValues(fromData);
}
Answer the question
In order to leave comments, you need to log in
Probably this is how it should work
/**
* @param {GoogleAppsScript.Events.SheetsOnEdit} e
*/
function onEdit(e) {
if (
e.range.getSheet().getName() === 'Sheet1' &&
e.range.getA1Notation() === 'M2'
)
CopyList();
}
/**
*
*/
function CopyList() {
var sss = SpreadsheetApp.openById('ID-ТАБЛИЦЫ1');
var ss = sss.getSheetByName('Sheet1');
var from = ss;
var fromValues = from.getDataRange().getValues();
var fromData = fromValues;
var tss = SpreadsheetApp.openById('ID-ТАБЛИЦЫ2');
var ts = tss.getSheetByName('Sheet2');
ts.getRange(
ts.getLastRow() + 1,
1,
fromData.length,
fromData[0].length
).setValues(fromData);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question