I found this script that will change a specified worksheet name based on a cell in that worksheet (from here ):
function renameSheet() {
var s = SpreadsheetApp.getActive().getSheets()[2];
s.setName(s.getRange(1, 2).getValue());
}
How would I modify this script to change all worksheet names (I'll use a trigger for every hour) based on the B1 cell in each worksheet?
Replace ID with the spreadheet's ID since it will not be active when accessed from the time trigger
function renameSheet() {
var s = SpreadsheetApp.openById(id).getSheets();
for(i in s) {
s[i].setName(s[i].getRange(1, 2).getValue());
}
}
A spreadsheet ID can be extracted from its URL. For example, the spreadsheet ID in the URL https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 is "abc1234567".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.