Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 多准则时间戳_Google Sheets - Fatal编程技术网

Google sheets 多准则时间戳

Google sheets 多准则时间戳,google-sheets,Google Sheets,我正在使用 function onEdit() { var s = SpreadsheetApp.getActiveSheet(); var r = s.getActiveCell(); var time = new Date(+new Date + (1000 * 60 * 60 * 24 * 7)); time = Utilities.formatDate(time, "GMT-08:00", "MM/dd/yyyy"); if( r.getColumn() == 2

我正在使用

function onEdit() {
  var s = SpreadsheetApp.getActiveSheet();
  var r = s.getActiveCell();
  var time = new Date(+new Date + (1000 * 60 * 60 * 24 * 7));
time = Utilities.formatDate(time, "GMT-08:00", "MM/dd/yyyy");
      if( r.getColumn() == 2 ) { //checks the column
      var nextCell = r.offset(0, 6);
      if( nextCell.getValue() === '' ) //is empty?
        nextCell.setValue(time);       
    }
}
…向H列添加时间戳+7天

除了这个时间戳功能。。。(可能是另一个脚本)

  • 当D列的值=为“问题/等待信息”,然后更改为任何其他内容时

  • 当列E value=“Premium,小于25kW”或“Premium,小于25kW”,然后更改为除“Premium,小于25kW”或“Premium,小于25kW”之外的任何内容时 我们想重新开始时间戳+7天

    这可能不适用于onEdit,因为在编辑之前必须读取一些值。不知道怎么做。谢谢


    正确,如果不先将原始数据复制到其他地方,使用onEdit是不可能的。这是我目前专业知识范围内的一个复杂解决方案。

    也许可以试试这样的解决方案

    function onEdit(e) {
    var d = new Date(new Date() + (1000 * 60 * 60 * 24 * 7));
    var time = Utilities.formatDate(d, "GMT-08:00", "MM/dd/yyyy"),
        ind = [2, 4].indexOf(e.range.columnStart),
        off;
    if (ind == 0) {
        off = 6;
    } else if (ind == 1 && e.value !== "Questions/Waiting for Info") {
        off = 4;
    }
    e.range.offset(0, off).setValue(time)
    }
    

    当D列更改为除“问题/等待信息”之外的任何内容,并且“12/31/1969”是新的时间戳时,此功能将起作用。这里的主要问题是,我认为onEdit函数不起作用。我还忘了另外一个标准,认为这个问题太夸张了。请参阅上面我的编辑。谢谢