'How can I hide rows in more than one Sheet using Apps Script?
I have been creating a complex spreadhseet on Google sheets that uses data from one 'tab' to populate information in other 'tabs'.
The way I have done this leaves gaps in the tables in the other 'tabs' and therefore I would like to be able to hide all of the rows that have gaps, in all of those specific 'tabs'.
/** @OnlyCurrentDoc */
function onOpen() {
SpreadsheetApp.getUi().createMenu("Custom Filter")
.addItem("Filter rows", "filterRows")
.addItem("Show all rows", "showAllRows")
.addToUi();
}
function filterRows() {
var sheet = SpreadsheetApp.getActive().getSheetByName("Jordan"); //Here, I need to find a way to specify more than one sheet
var data = sheet.getDataRange().getValues();
for(var i = 5; i < data.length; i++) {
//If column B is blank then hide the row.
if(data[i][1] === "") {
sheet.hideRows(i + 1);
}
}
}
function showAllRows() {
var sheet = SpreadsheetApp.getActive().getSheetByName("Jordan");
sheet.showRows(1, sheet.getMaxRows());
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
