Home > Blockchain >  Auto hide rows in google sheets using app script
Auto hide rows in google sheets using app script

Time:02-24

i have an issue with my sheet, i usually insert data manually and need to fill every row, the issue is when you get more than 3000 rows is a pain to always scroll to the bottom (even with shortcut) and start filling, therefore i am trying to create an app script that auto hides row for example, every 10 new rows auto hide, in my actual sheet would be a higher number, but just for testing purposes i have a sheet bellow with some dummy data, and i would like to auto hide every new 10 rows, is this even possible?

Link to the sheet

CodePudding user response:

You can achieve that by recording a macro. Here's the script it creates

function hideRows() {
  var spreadsheet = SpreadsheetApp.getActive();
  var sheet = spreadsheet.getActiveSheet();
  sheet.getRange(spreadsheet.getCurrentCell().getRow() - 1, 1, 10, sheet.getMaxColumns()).activate();
  sheet = spreadsheet.getActiveSheet();
  var selectionAfterHide = sheet.getRange(spreadsheet.getCurrentCell().getRow()   10, 1, 1, sheet.getMaxColumns());
  spreadsheet.getActiveSheet().hideRows(spreadsheet.getActiveRange().getRow(), spreadsheet.getActiveRange().getNumRows());
  selectionAfterHide.activate();
};
  • Related