Scroll Horizontally to Cell

302 views
Skip to first unread message

Kevin -

unread,
Jul 20, 2022, 3:31:31 AM7/20/22
to Google Apps Script Community
Using Goggle Sheets app script to make a monthly "calendar" which is 50+ columns wide. When the sheet opens I want the column representing today's date to be in the center of the screen. Is there a way to do this? getRange().activate does not work.

Edward Ulle

unread,
Jul 20, 2022, 6:54:44 AM7/20/22
to Google Apps Script Community
Try this.

function onOpen(e) {
  e.source.getActiveSheet().setActiveSelection("C1");  // will put the cursor in cell C1
}


Kevin -

unread,
Jul 21, 2022, 6:35:53 AM7/21/22
to Google Apps Script Community
Thanks, that's a great clue --  setActiveSelection.  I need to position the column with cell value TODAY in the middle of the screen (this is a wide sheet with 50+ columns). It looks like setActiveSelection will scroll right to display the cell (try "AH1" instead of "C1") to the right visible edge of the screen. I can do some math to display a column further to the right and that should put TODAY close to the middle. 
Reply all
Reply to author
Forward
0 new messages