I need to create a script to based on the date in column B to change the background color of the row from column B to column d based on if the date in column b is one day, two days, three days, etc. ahead of today.
I have found some code from another post however it is evaluating multiple rows with dates
function formatting() {
var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Schedule Fields');
var rg=sheet.getDataRange();//this range starts at column 1
var vA=rg.getValues();
var today = new Date();
for(var i=0;i<vA.length; i++){
for(var j=1;j<=1;j++){//j=2 is the third column
var bullDate = new Date(vA[i][j]);
if (bullDate < today){
sheet.getRange(i+1,j+1).setBackgroundColor('yellow');
}
}
}
}
I was able to change this code enough to get the background color of a date in column B. I'm not sure how to change this to set background color of ColB-ColD and then add onto the if condition to equate for 1 day 2 day 3 day etc. in the future of today.
function formatting() {
var sheet=SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Form Responses');
var rg=sheet.getDataRange();//this range starts at column 1
var vA=rg.getValues();
var today = new Date();
for(var i=0;i<vA.length; i++){
for(var j=2;j<=4;j++){//j=2 is the third column
var bullDate = new Date(vA[i][j]);
if (bullDate < today){
sheet.getRange(i+1,j+1).setBackgroundColor('yellow');
}
}
}
}
This is the complete original snippet I used from conditionally formatting cells based on date