I'm attempting to remove rows from a sheet based on criteria. I found the following code that works beautifully for what I need:
Delete a row in Google Spreadsheets if value of cell in said row is 0 or blank
However, it isn't clear how the column is being specified. I don't see a
e.range.columnStart == 3
like in other answers.
Any guidance on how to read it?
**
* Deletes rows in the active spreadsheet that contain 0 or
* a blank valuein column "C".
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
var rowsDeleted = 0;
for (var i = 2; i <= numRows - 1; i++) {
var row = values[i];
if (row[2] > 1.5 || row[2] < 1) {
sheet.deleteRow((parseInt(i)+1) - rowsDeleted);
rowsDeleted++;
}
}
};