Home > Mobile >  Hide sheet at the click of a button
Hide sheet at the click of a button

Time:08-24

I've run into another roadblock.
I am simply trying to create a script to map to a button to hide the current sheet the button is being clicked.
That way user doesn't have to right click tab to hide the sheet. I have tried the following

function hideSheet() {
  sourceSpreadsheet = SpreadsheetApp.getActive();
  SpreadsheetApp.getActive().hideSheet();
}

Cannot get it to work.

CodePudding user response:

Try it this way:

function hideActiveSheet() {
  SpreadsheetApp.getActiveSheet().hideSheet();
}

CodePudding user response:

SpreadsheetApp.getActive() is the same as SpreadsheetApp.getActiveSpreadsheet(), they return a Class Spreadsheet object, in other words, these methods returns a spreadsheet also called workbook, not a sheet.

Instead use SpreadsheetApp.getActiveSheet() which returns a sheet.

  • Related