I have a Google Docs SpreadSheet, where in the column A are dates (A1: 2013-11-22, A2: 2013-11-23, A3: 2013-11-24 etc). I would like to automatically highlight - set a backg
If you want it to be automatic on spreadsheet open you will have to install an installable onOpen that will call the below function (from script editor goto ressources > this script triggers > add a new trigger > sreadsheet / on Open)
And here is the code for columns: (see below for rows)
function customOnOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var headers = sh.getRange(1,1,1,sh.getLastColumn()).getValues();
var today = new Date().setHours(0,0,0,0);
for(var n=0;n=2){sh.getRange(1,n-1,sh.getMaxRows(),1).setBackground(null);};// resets the backGround for yesterday if not the first column
sh.getRange(1,n,sh.getMaxRows(),1).setBackground('yellow');
break;
}
}
}
this version to colorize rows
function customOnOpen2() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var headers = sh.getRange(1,1,sh.getLastRow()).getValues();
var today = new Date().setHours(0,0,0,0);
for(var n=0;n=2){sh.getRange(n-1,1,1,sh.getMaxColumns()).setBackground(null);}
sh.getRange(n,1,1,sh.getMaxColumns()).setBackground('yellow');
break;
}
}
}
Note : if you want it to run fully automatically based on a timer it's perfectly doable, just change the ss and sh variable using openById and getSheetByName (see doc here)and set up a timer to make it run every day around 1 AM.