I have a google sheets file where I filter rows based on a single column criteria. if certain cell in a column is empty, I filter that entire row. But right now my problem is that I am trying to set Background color to the filtered row. But I keep getting this error: "TypeError: rows.filter(...).setBackground is not a function" when I try the following code:
var mydata3 = rows.filter(row => row[8] == '').setBackground("red");
Does anyone know how I can achieve this or is there any work around? Because I can see that setBackground is not the data type as mydata3 which is basically a filtered row.
Thanks.
var sss = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
var sheetID = sss.getSheetId(); // get the id of first page
var values = sss.getDataRange().getValues();
var getRangeRow2 = sss.getDataRange().getRow()[5];
var getRangeCol2 = sss.getDataRange().getColumn()[1];
function insertRecord() {
var sheet_1 = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
var headerRowNumber = 3;
var rows = sheet_1.getDataRange().offset(headerRowNumber, 0, sheet_1.getLastRow() -
headerRowNumber).getValues();
var mydata3 = rows.filter(row => row[8] == '');
}