將以下代碼複製並粘貼到腳本編輯器中。運行在Open上,它會創建一個菜單。您可以從菜單中運行該功能。它會將您的報告行復制到名爲歷史記錄的工作表,然後刪除複製的報告行。如果您有任何問題,請告訴我。
function onOpen() {
SpreadsheetApp.getActiveSpreadsheet().addMenu(
'Weekly Report', [
{ name: 'Move to History', functionName: 'moveRow' },
]);
}
function moveRow() {
// assumes source data in sheet named Report
// target sheet of move to named History. Change the name to what you want.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName("Report");
var row = s.getLastRow();
var numColumns = s.getLastColumn();
var targetSheet = ss.getSheetByName("History");
var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
s.getRange(row, 1, 1, numColumns).moveTo(target);
s.deleteRow(row);//delete just moved data from report. You may not want to do this.
}