This is what I have so far, which does not successfully run and I cannot identify why:
var values = Today.getRange('C6:C').getValues();
var a = 0;
while (a<=values.length){
if ( values[a][0] == "True" ) {
Today.deleteRow(a+6); //Here I add 6 to 'a' since the range 'values' started from row 6.
}
a++ //Increase 'a' by 1 and continue.
}
If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.
In this pattern, Spreadsheet service like SpreadsheetApp
is used.
function myFunction() {
var sheetName = "Today"; // Please set the sheet name.
var Today = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var values = Today.getRange('C6:C' + Today.getLastRow()).getValues();
for (var i = values.length - 1; i >= 0; i--) {
if (values[i][0]) Today.deleteRow(i + 6);
}
}
In this pattern, Sheets API is used. So please enable Sheets API at Advanced Google services. When the number of delete rows is large, the process cost of this method is lower than that of the pattern 1.
function myFunction() {
var sheetName = "Today"; // Please set the sheet name.
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
var sheetId = sheet.getSheetId();
var values = sheet.getRange('C6:C' + sheet.getLastRow()).getValues();
var requests = values.reduce(function(ar, [e], i) {
if (e) ar.push({deleteDimension:{range:{sheetId:sheetId,dimension:"ROWS",startIndex:(i + 5),endIndex:(i + 6)}}});
return ar;
}, []).reverse();
Sheets.Spreadsheets.batchUpdate({requests: requests}, ss.getId());
}
If I misunderstood your question and this was not the direction you want, I apologize.