I'm no pro but I need this Google Script for my spreadsheet. I was searching for puzzle pieces to build my code. At the end it works but very slow. Can someone help me? I can see in slowmotion how the code works. :-(
My spreadsheet or sheet has a lot of entries but some rows are empty (over 1000 rows). With the filter function I can hide these rows very fast, just in seconds. I'm not the user of the spreadsheet only the creator. The normal users are really no experts and using the filter function is a challange for them. I thought I can combine all steps in a script and make it usable with a button. One part is hiding the empty rows.
The script checks in column N whether there is 1 or 0. If there is a 0, then the row shall be hidden. The script starts in row 7 till 1150. Hiding one row needs one second each! This is really slowmotion. Is it possible to activate the filter function by script alternatively if my code is rubbish?
function hideRows() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setActiveSheet(ss.getSheetByName("Order"));
var sheet = SpreadsheetApp.getActiveSheet();
var column = 14;
var cell = 0;
var lastRow = SpreadsheetApp.getActiveSheet().getLastRow();
for (var row = 7; row < lastRow; row++) {
cell = sheet.getRange(row, column).getValues();
if (cell == 0){
sheet.hideRows(row);
}
else {
sheet.showRows(row);
}
}
}