這是我的代碼,我試圖讓oldmonths標簽復制自己,并將自己命名為newmonths名稱,但我只是想不出如何讓最后一部分工作。
var oldMonthName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("X2").getRange("U4").getValue();//name for the old month, formula in X2
var newMonthName = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("X2").getRange("U3").getValue();//name for new month, formula in X2
var oldMonthTab = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(oldMonthName);//old month tab, used to be able to hide it
var destination = SpreadsheetApp.openById('1lQ10rgciG5WiUQ0uVQc1E7r7Qwd6hOkZQSaH');//chooses this spreadsheet, the ID should come from the URL of the sheet it will be copied to.
oldMonthTab.copyTo(destination).setname(newMonthTab);//makes a copy of old month and sets the name to new month```
變量
newMonthTab
未定義。使用此項: