Focus Sheet on Cell with Date
Jordan Rhea
Jordan Rhea
Software developer using code to bridge the gap between technology and education, ensuring a seamless integration of data software, and empowering schools to make informed choices for improved student outcomes.
Have to share a quick snippet I wrote today after getting frustrated scrolling all over spreadsheets looking for today's date. Maybe this will be helpful to someone else
function focus()
const sheet = SpreadsheetApp.getActive().getSheetByName(SHEET_NAME);
const range = sheet.getDataRange();
const vals = range.getValues();
const today = new Date();
for(let y = 0; y < vals.length; y++) {
const x = vals[y].findIndex(cell => cell instanceof Date && cell.toDateString() === today.toDateString());
if(x > -1) {
return sheet.getRange(y + 1, x + 1).activate();
}
}
}{