我的脚本可以很好地将“源工作表”行移动到“目标工作表”的最后一行。但是,我希望将“源工作表”中已删除的行粘贴到第一行(第2行为第1行是标题)。谢谢您的帮助。
function onEdit(event) {
// assumes source data in sheet named Service Log
// target sheet of move to named Completed
// test column with Completed is col 26 or Z
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = event.source.getActiveSheet();
var r = event.source.getActiveRange();
if (s.getName() == "Service Log" && r.getColumn() == 26 && r.getValue()
== "Completed") {
var row = r.getRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("Completed");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).moveTo(target);
s.deleteRow(row);
}
}