We had multiple scripts for one sheet and seemed to operate independently but once combined to one script, it seems not to work. It executes but no activity on sheet. Trying to get these on one script so we can add a custom menu to execute the script.
function removeRows() {
var sheetName = "DBDR_AllDevicesTAB"; // Replace with your sheet name var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName); var range = sheet.getDataRange(); var flVals = range.getFontLines();
for (var i = flVals.length - 1; i >= 0; i--) {
for (var j = 0; j < flVals[i].length; j++) {
var cellFL = flVals[i][j]; // console.log(cellFL.getFontLine()) if (cellFL == "line-through") { sheet.deleteRow(i + 1); break; // Move to the next row if a strikethrough cellFL is found }
}
}
}
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
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[1].indexOf('Food System') > -1) {
sheet.deleteRow((parseInt(i) + 1) - rowsDeleted);
rowsDeleted++;
}
}
};
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
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].indexOf('Standalone') > -1) {
sheet.deleteRow((parseInt(i) + 1) - rowsDeleted);
rowsDeleted++;
}
}
};
2
Answers
Use OR Logic
I combined your code into a single function and added a custom menu to easily run the script in the spreadsheet. Kindly copy and paste the code to check if it works on your end.
It removes rows with
strike-through text
and rows with"Food System"
on Column B and"Standalone"
on Column H.Here is the code:
Sample Output:
Before running the script:
After running the script:
References:
Logical Operator
onOpen(e)
Try it this way: