在给定特定值时,我需要自动复制一行。
使用Moveto
可以,但是使用copyto
则不能。
有人可以帮助我吗? tx
function myFunction3() {
var sheetNameToWatch = "Planning";
var columnNumberToWatch = 12;
var valueToWatch = "Running";
var sheetNameCopyTheRowTo = "Facturatie";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var rangeToCopy = sheet.getActiveCell();
if (sheet.getName() == sheetNameToWatch
&& range.getColumn() == columnNumberToWatch
&& range.getValue() == valueToWatch)
{
var targetSheet = ss.getSheetByName(sheetNameToMoveTheRowTo);
var targetRange = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
sheet.getRange(range.getRow(),1,1,sheet.getLastColumn()).copyTo(targetRange);
}
}