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

后端 未结 3 1947
庸人自扰
庸人自扰 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:40

    function onOpen() {
      // Activate cell with current date
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(),
          data = sheet.getDataRange().getValues(),
          now = new Date(),
          columnWithDate = 0,
          i, delta,
          epsilonInMs = 0;
      for (i = 0; data.length > i; i++) {
        delta = now - new Date(data[i][columnWithDate]);
        if (delta < epsilonInMs) break;
      }
      sheet.getRange(i, columnWithDate + 1).activate();
    }
    

提交回复
热议问题