I have the below script that is to search for 'Dead' or 'Booked' in range "S:S" and hide the row if it is found. If 'Live' is found in a hidden row it should unhide the Row. The below script is working however, it unhides all rows and then completes the function, which can take a while when over 1000 rows are being searched.
function RowHide(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sht2 = ss.getSheetByName("Log");
var row = sht2.getRange("S:S").getDisplayValues();
sht2.showRows(1, sht2.getMaxRows()); {
for (var i = 0; i < row.length; i++) {
if (row[i][0] == 'Dead') {
sht2.hideRows(i + 1, 1);
}
if (row[i][0] == 'Booked') {
sht2.hideRows(i + 1, 1);
} else if (row[i][0] == 'Live') {
sht2.showRows(i + 1, 1);
}
}
}
}
I need to alter the script to only action rows which require action rather than all of them. Is this possible?
Hiding Rows with onEdit trigger
Hiding and Showing with onEdit Trigger