JavaScript To Dynamically & Daily Advance To The Next Worksheet In An Open Google Sheets File



At work using Chrome, I have a Google Sheets file saved on my Google Drive folder with edit privileges that's shared with me. I always keep the file open on my MacBook Pro.

After I've originally opened the file and selected the current day's worksheet, I would like a JavaScript that dynamically selects the next day's worksheet at (12:00 AM - 12:15 AM) every 24 hours. Each (1 - 31) worksheets has daily information for the current month.

Using the following recommended script with a 1-minute test trigger, the worksheet does not seem to be activated. I need assistance either debugging or understanding why the trigger doesn't fire. Any suggestions?

function nextSheet() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var numSheets = ss.getSheets().length; // number of sheets
var activeSheetIndex = ss.getActiveSheet().getIndex() - 1; // see below
var newSheetIndex = (activeSheetIndex + 1) % numSheets; // add 1; wrap around