I have a spreadsheet where I want to search row by row and compare the value in column O to one on my "Menu" page. If the value in column O is less than the value of Menu, turn the whole row red.
This is what I have so far but it's not working.
function checkDate(sheet){
menu = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Menu");
var rows = sheet.getDataRange().getValues();
for(var i=0; i < rows.length; i ){
if(rows[i][14] > menu.getRange("B5").getValue()){
var changeRange = sheet.getRange(1,i,1,sheet.getLastColumn());
changeRange.setBackgroundRGB(255, 0, 0);
}
}
}
CodePudding user response:
This appears to work...
function checkDate(sheetName){
menu = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("menu");
sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var rows = sheet.getDataRange().getValues();
console.log(sheet.getName());
for(var i=0; i < rows.length; i ){
if(rows[i][14] > menu.getRange("B5").getValue()){
sheet.getRange(i 1,1,1,sheet.getLastColumn()).setBackgroundRGB(255, 0, 0);
}
}
}