I'm running a script to remove rows that contain a text string in a Google Sheet. My target spreadsheet has 50k rows and I'm running into max execution time limits (1 hr per day and 6 min per run). I believe my script could be bloated and I'm not sure how to optimize it.
Note: I am not the author of this code.
function deleteRows() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('All Marketplaces Removed');
var r = s.getRange('B:B');
var v = r.getValues();
for(var i=v.length-1;i>=1;i--)
if(v[i][0].includes("amazon")) {
s.deleteRow(i+1);
}
};