【发布时间】:2023-01-01 23:44:14
【问题描述】:
这是我的代码,我试图让 oldmonthtab 复制自己并将自己命名为 newmonthname,但我只是想不出如何让最后一部分工作。
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```
【问题讨论】:
标签: google-apps-script google-sheets