Reputation: 361
I would like to modify this code so that if there is any data(Numbers as well) in column 7, it will delete the entire row.
Currently whatever you put into the inverted commas in the If Statement, it deletes
what could you substitute that would do that ?
function DeleteCOMPLETED2() {
var sheet = SpreadsheetApp.getActive();
sheet.setActiveSheet(sheet.getSheetByName('RELOCATION'), true);
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
var rowsDeleted = 0;
for (var i = 0; i <= numRows - 1; i++) {
var row = values[i];
if (row[7] == "**if there is any data in column 7 then delete entire row**") {
sheet.deleteRow((parseInt(i)+1) - rowsDeleted);
rowsDeleted++;
}}}
Upvotes: 0
Views: 50
Reputation: 64110
Delete row if anything in column7
function DeleteCOMPLETED2() {
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('RELOCATION');
var values=sh.getDataRange().getValues();
var d=0;
values.forEach(function(r,i){if(r[6]){sh.deleteRow(i+1-d++);}});//column7
}
Upvotes: 1