Google spreadsheet / docs , jump to current date cell on Open

后端 未结 3 1982
庸人自扰
庸人自扰 2021-01-06 11:01

I\'ve searched for this topic and have found a few threads - however, none of the answers (usually in the form of scripts) in those topics have proven to be successful to me

3条回答
  •  醉酒成梦
    2021-01-06 11:51

    This works when dates are in first column (column A) and you want to go to the row near the current date (you can tweak the numbers to suit):

    function onOpen() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getActiveSheet();
    var d1 = new Date().getTime();
    var a; 
    for (a = 1; (Math.floor((d1-sheet.getRange(a,1).getValue())/86400000)) > 5; a++) 
    
    try {    var range = sheet.getRange(a+25,2);  } 
      catch(err) {    var range = sheet.getRange(2, 2)  }
    sheet.setActiveSelection(range);
    }
    

提交回复
热议问题