Reputation: 101
So I'm using this script below (credit: Eduardo Kuwakino). The problem I have that it hides the rows from column A:A with the value "x" one by one. Is it possible to make this "less painful" for the people who are editing these spreadsheets?
function hideCells(sheet)
{
var maxRows = sheet.getMaxRows();
//show all the rows
sheet.showRows(1, maxRows);
//get data from clumn A
var data = sheet.getRange('A:A').getValues();
//iterate over all rows
for(var i=0; i< data.length; i++){
//compare first character, if asterisk, then hide row
if(data[i][0].charAt(0) == 'x'){
sheet.hideRows(i+1);
}
}}
function onOpen() {
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
for(var i=0; i< sheets.length; i++){
hideCells(sheets[i]);
}
}
Upvotes: 1
Views: 796
Reputation:
There is a method hideRows which can hide several rows at once, but they must be consecutive. In your situation, the rows will not be consecutive in general. So script has to hide them one by one (or maybe in groups when a few happen to be together, but I don't think this will help much). And indeed, this will be slow in a large sheet.
As an alternative, I suggest using a filter view, specifically filter the sheet by the column A with custom formula =A2<>"x"
Each filter view has its own URL, which can be sent to people editing the spreadsheet. They will see only the rows where the value in A is different from "x".
Upvotes: 3