I've got an annual calendar split by week, and a whole bunch of content cells in between each week. Essentially, B2:F2 has Jan 1 to Jan 5, and then B15:F15 has Jan 9 to Jan 15, for example.
I'm trying to get this sheet to open on the cell containing Todays date, but the below script allows me to search for 'Today' in just one column (D:D). I'm not able to get it to work on the entire sheet.
So far I have:
function onOpen() {
var menu = [{name: "Jump to today's date", functionName: "jumpToDate"}];
SpreadsheetApp.getActiveSpreadsheet().addMenu("Custom", menu);
jumpToDate();
}
function jumpToDate() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var range = sheet.getRange("D:D");
var values = range.getValues();
var day = 24*3600*1000;
var today = parseInt((new Date().setHours(0,0,0,0))/day);
var ssdate;
for (var i=0; i<values.length; i++) {
try {
ssdate = values[i][0].getTime()/day;
}
catch(e) {
}
if (ssdate && Math.floor(ssdate) == today) {
sheet.setActiveRange(range.offset(i,0,1,1));
break;
}
}
Logger.log(ssdate);
}
This seems to only work on column D, but every time I try to expand the range in this line: It doesn't work.
var range = sheet.getRange("Invoice!B2:F500");
Does anyone know how I could make this work?
NOte: I did not write this script, I got it off this thread :)
Thank you!
Edit:
We only go off a 5 day week (Monday to Friday)
Here's what the sheet looks like: https://docs.google.com/spreadsheets/d/1JQxXy-ErVKATh5cUCD7u6QLQkaDyXfhhGuMKs_xgbh4/edit?usp=sharing
And here's an image: spreadhseetexample
B15:F15- Cooper