Skip to content

Instantly share code, notes, and snippets.

@phillypb
Created November 30, 2022 09:55
Show Gist options
  • Save phillypb/b4333491ef8296b5362847bccc823788 to your computer and use it in GitHub Desktop.
Save phillypb/b4333491ef8296b5362847bccc823788 to your computer and use it in GitHub Desktop.
function switchActiveView() {
// get spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
// get cell range in destination sheet that the view will be switched to
var range = ss.getRange('Sheet2!A1');
// activate cell range so cursor moves to that position and changes the current view
range.activateAsCurrentCell();
}
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Admin')
.addItem('Switch view', 'switchActiveView') // label for menu item, name of function to run.
.addToUi();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment