Home > database >  Automatic scroll right google sheet script
Automatic scroll right google sheet script

Time:06-01

I need a script or setting in Google Sheet, where it will automatically scroll to the last column on the right. The only thing I found were scripts for automatic scrolling down, but I don't need that, I need to scroll all the way to the right, not down. So, this is the script that I found, and it doing great job. I need something like this, but for the right side, to the last column in file.

function onOpen(){
 let ss = SpreadsheetApp.getActiveSpreadsheet();
 let sheet = ss.getSheetByName(ss.getSheets()[0].getName());
 sheet.setActiveRange(sheet.getRange(sheet.getLastRow(),1));
}

CodePudding user response:

You need to specify the Range correctly in the sheet.setActiveRange function. Check out the following script.

function onOpen(e) {
  let ss = SpreadsheetApp.getActiveSpreadsheet();
  let sheet = ss.getSheetByName(ss.getSheets()[0].getName());
  sheet.setActiveRange(sheet.getRange(1,sheet.getLastColumn()));
}

CodePudding user response:

Try this:

function myfunk() {
  const ss = SpreadsheetApp.getActive()
  const sh = ss.getSheetByName("Sheet0");
  const vs = sh.getDataRange().getValues();
  sh.hideColumns(1,sh.getLastColumn());
}
  • Related