I am very new to using scripts in Google Sheets, but found this simple and useful piece of code online. I am trying to hide rows in a specific range (rows 10 - 34) where the cells in column E are blank. The code below seems to hide all rows in the range regardless, even those that have a number in column E.
I have tried:
data[i][3] = 'null',
data[i][4] = 'null',
data[i][5] = 'null'
Any idea where I'm going wrong?
Thanks so much for any help.
function filterRows() {
var sheet = SpreadsheetApp.getActive().getSheetByName("Print Client Report");
var data = sheet.getDataRange().getValues();
for(var i = 9; i < 34; i++) {
//If column E (5th column) is "Y" then hide the row.
if(data[i][3] = 'null') {
sheet.hideRows(i + 1);
}
}
}
function filterRows() {
var sheet = SpreadsheetApp.getActive().getSheetByName("Print Client Report");
var data = sheet.getRange(10, 1, 25, sheet.getLastColumn()).getValues();
data.forEach((r, i) => {
if (!r[4]) {
sheet.hideRows(i + 10);
}
});
}