Se vuoi che sia automatico sul foglio di calcolo aperto devi installare un oggetto installabile su Open che chiamerà la funzione seguente (da editor di script goto risorse> questo trigger di script> aggiungi un nuovo trigger> foglio di lavoro/su Apri)
E qui è il codice per le colonne: (vedi sotto per le righe)
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<headers[0].length;++n){
var date = new Date(headers[0][n]).setHours(0,0,0,0);
Logger.log(today+' =? '+date)
if(date==today){
n++
Logger.log('match on column '+n)
if(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;
}
}
}
questa versione per colorare le righe
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<headers.length;++n){
var date = new Date(headers[n][0]).setHours(0,0,0,0);
Logger.log(today+' =? '+date)
if(date==today){
n++
Logger.log('match on column '+n)
if(n>=2){sh.getRange(n-1,1,1,sh.getMaxColumns()).setBackground(null);}
sh.getRange(n,1,1,sh.getMaxColumns()).setBackground('yellow');
break;
}
}
}
Nota: se si vuoi che venga eseguito automaticamente in base a un timer è perfettamente fattibile, basta cambiare la variabile ss e sh usando openById
e getSheetByName
(see doc here) e impostare un timer per farlo funzionare tutti i giorni intorno all'una.
ci dovrebbe essere; nella funzione ARRAYFORMULA, ma grazie per un esempio – machj