Automatic timestamp when a cell is filled out

前端 未结 6 2047
感情败类
感情败类 2020-11-29 06:33

I have an excel formula that is very simple and it works because I can restrict the recursive iterations. I am not very script savvy, but this is what it is and it works.

6条回答
  •  青春惊慌失措
    2020-11-29 06:45

    Just addition to above code FOR Multi Column AutoStamp in Same Sheet

    function onEdit() {
      var s = SpreadsheetApp.getActiveSheet();
      if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet
        var r = s.getActiveCell();
        if( r.getColumn() == 5 ) { //checks the column
          var nextCell = r.offset(0, 1);
          //if( nextCell.getValue() !== '' ) //is empty?
          nextCell.setValue(new Date());
        }
    
        if( r.getColumn() == 7 ) { //checks the column
          var nextCell = r.offset(0, 1);
          //if( nextCell.getValue() !== '' ) //is empty?
          nextCell.setValue(new Date());
        }
    
        if( r.getColumn() == 9 ) { //checks the column
          var nextCell = r.offset(0, 1);
          //if( nextCell.getValue() !== '' ) //is empty?
          nextCell.setValue(new Date());
        }
      }
    }
    

提交回复
热议问题