How to make it possible to run the script every night at 23:00, the sheet name's based on that day's date, e.g. today's date (2022.02.11)
the sheet: 2022.02.11 move it to the last place in the tabs?
as an example I would like to achieve this with script
since, it should work on android and other platforms, i think its not an option to have a sidebar or maybe a macro..
I found one like this, but it just does what you do when you click on an active sheet moves it to left
function tab() {
var reportDate = new Date();
var tabName = Utilities.formatDate(reportDate, "GMT ", 'yyyy.MM.dd').toString();
var tab = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(tabName);
SpreadsheetApp.setActiveSheet(tab);
SpreadsheetApp.getActiveSpreadsheet().moveActiveSheet(1);
}
it was mentioned familiar here, and this script above is also from there, I just changed the date format to mine Move Sheet Tab to the Far Left Using Script
Thanks in advance for your help!
CodePudding user response:
In order to move a tab to the most right side, in your script, how about the following modification?
Modified script:
function tab() {
var reportDate = new Date();
var tabName = Utilities.formatDate(reportDate, "GMT ", 'yyyy.MM.dd').toString();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var tab = ss.getSheetByName(tabName);
SpreadsheetApp.setActiveSheet(tab);
SpreadsheetApp.getActiveSpreadsheet().moveActiveSheet(ss.getSheets().length);
}
- When you want to run this script at 23:00, please install the time-driven trigger. Ref