I have a Google spreadsheet with multiple sheets. I would like the cursor to be set to a particular cell onOpen
for all tabs. Each cell of the first row represents
Looks like you need to make a call to SpreadsheetApp.flush() when you loop over the sheets collection:
function onOpen() {
SpreadsheetApp.getActive().getSheets().forEach(function (s) {
s.setActiveSelection("B4");
SpreadsheetApp.flush(); // Force this update to happen
});
}
My guess is Apps Script's execution engine optimizes the writes to a single call, and in that single call only one active selection can be made. Calling flush forces 1 call per sheet to be updated.