I am attempting to hide rows based on a value in the cell.
I am using Google Sheets as an Inventory for items. On the last column if I mark it "Yes" I'd like the whole row to hide.
The code works on a template sheet, but when I try to activate it on my main Inventory it says "Exceeded Maximum Execution Time", which I would assume is happening because it is quite a large Inventory.
function onEdit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var lastRow = sheet.getLastRow();
for( i=1 ; i<=lastRow ; i++) { // i <= lastRow
var status = sheet.getRange("AD"+i).getValue();
if (status == "Yes") {
sheet.hideRows(i);
}
}
}
I do see that on the Triggers you can set it up to be Time-driven.
How can I make the code not exceed the 5 minute Maximum Time?