Hello dear community,
I am unfortunately not able to figure out where's the issue in @Serge insas AppScript to jump to Today's cell in my own spreadsheet.
Fixed potential issue with different timezones date format, however, the script jumps to the last cell as: sh.getRange(5,sh.getLastColumn()).activate();
indicates, but not to Today's cell.
Important to mention that my Spreadsheet is constructed horizontal, here is the link
Here is my version:
function JumpToToday() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
sh.getRange(5,sh.getLastColumn()).activate();
var data = sh.getDataRange("E5:NE5").getValues();
var offsetToSS = new Date('22/02/2022').setHours(0,0,0,0);
var today = parseInt((new Date().setHours(0,0,0,0)-offsetToSS)/86400000,10)+1;
for(var n=0;n<data[0].length;n++){
var date = data[0][n];
Logger.log("date = "+data[0][n]+" =? "+today);
if(date==today){break};
}
n++;
sh.getRange(1,n).activate();
}
Can the issue be due to the script going first to last column and then starts counting from n=0?