【问题标题】:Google sheet date of last revision in a row连续最后一次修订的 Google 表格日期
【发布时间】:2015-09-25 10:21:10
【问题描述】:

帮助! 在 Google 表格中,我只希望一列输入更新或修改行中任何单元格的最后日期和时间。 例如: a1 - 应该得到最后的修订日期, b1-z1(a1 之后的任意数量的单元格)- 每次更新或修改该行中的任何单元格时,都会更新 a1 日期。

我想将相同的脚本应用到多张纸上。

我发现了这个脚本,最初似乎工作正常:

function onEdit(event){
  var ss = SpreadsheetApp.getActiveSpreadsheet();


  //Script Last Update Timing

  var actSht = event.source.getActiveSheet();
  var actRng = event.source.getActiveRange();

  var activeCell = actSht.getActiveCell();
  var row = activeCell.getRow();
  var column = activeCell.getColumn();

  if(row < 2)   return; //If header row then return
    var colNums  = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,  20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]; //Coulmns, whose edit is considered
  if(colNums.indexOf(column) == -1) return; //If column other than considered then return


  var index = actRng.getRowIndex();
  var dateCol = actSht.getLastColumn();
  var lastCell = actSht.getRange(index,dateCol);
  var date = Utilities.formatDate(new Date(), "GMT+5:30", "dd/MM/yyyy HH:mm:ss");
  // Note: Insert the Date when someone update the row in the last coulmn
  lastCell.setValue(date);
}

当我测试它时,它运行良好,但在那天之后它不工作,或者有时它工作,或者当我自己进行修订时工作,但它不适用于我共享文件的人与。

我对脚本一无所知,但经过一周的搜索,我选择发帖,希望有人能引导我走向正确的方向。

任何帮助将不胜感激!提前谢谢!

【问题讨论】:

    标签: date google-sheets timestamp datestamp


    【解决方案1】:

    看看这是否有帮助:

    function onEdit(e) {
    if (e.range.columnStart < 5 || e.range.rowStart < 21) return;
    e.source.getActiveSheet().getRange(e.range.rowStart, 1) //first col
        .setValue(Utilities.formatDate(new Date(), "GMT+5:30", "dd/MM/yyyy HH:mm:ss"));
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-23
      • 2019-07-25
      • 1970-01-01
      • 1970-01-01
      • 2021-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多