Automatic timestamp when a cell is filled out

前端 未结 6 1953
感情败类
感情败类 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:37

    it's much easier than that! =now

    or;

    =today

    Depending what you need

    0 讨论(0)
  • 2020-11-29 06:42

    I set the timestamp to include HH:MM:SS but upon testing the stamp 4 times in under a minute I get: 03,14,11,07 fluctuate as the MM in my timestamp.

    0 讨论(0)
  • 2020-11-29 06:44

    Stackoverflow is a place to ask questions related to programming, e.g. that you're actually working on. Not really asking for others to develop it for you, i.e. you didn't even started trying any Apps Script code yet. I recommend you reading its tutorials and guides. It's really easy to start.

    Anyway, just to help you get started, I'll drop everything you said and stick to the question title: "automatic timestamp when a cell is filled out"

    I advise you to do it all on apps script, and drop your formulas entirely, e.g.

    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() == 4 ) { //checks the column
          var nextCell = r.offset(0, 1);
          if( nextCell.getValue() === '' ) //is empty?
            nextCell.setValue(new Date());
        }
      }
    }
    

    This code does what I understood from yours, which is: if something is edited on column D and column E is empty, add the current date to E.

    0 讨论(0)
  • 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());
        }
      }
    }
    
    0 讨论(0)
  • 2020-11-29 06:59

    Actually, in this case you don't have to script anything. Google (or someone) has done it already. In your Google spreadsheet, go to "Insert -> Script" and search on "time". There are two ready-made scripts which will do what you want. I found "Cell Last Modified Date" works perfectly. Select it and click the "Install" button. You can reformat the column to show date, date+time, and so on. You can also hand code a date in the column, or move them from another column if you were tracking it before, and they will stay as you set them. But updating any cell in the row will update the timestamp.

    0 讨论(0)
  • 2020-11-29 07:03

    and if you want it to update if the cell is changed again just delete this line

    if( nextCell.getValue() !== '' ) //is empty?
    

    By the way, how can the date be formatted to ie. dd/mm/yyyy instead of the default dd/mm/yyyy hh:MM:ss format

    0 讨论(0)
提交回复
热议问题