简体   繁体   中英

Google sheets Time Stamp “Matrix”

I am looking for solution how to create time stamps in google sheets but not only in one column and not in the same Tab. I need to get time everytime if user will populate any figure in the table with size 50 columns x 30 rows.

Example.

Figure populated in cell C5 Sheet1 = Timestamp in cell C5 Sheet2.

Figure populated in cell F15 Sheet1 = Timestamp in cell F15 Sheet2

At this moment I know how to create Time stamp but only for one column in the same Tab as Populated figure but it is not what exactly I need. Much apreciated for any help or suggestion!

Regards

You can use Apps Script. It has a simple trigger onEdit(e) which can be used for that:

function onEdit(e) {
  const { range, source: spreadsheet } = e

  // Do something only if Sheet1 is the one being edited
  if (range.getSheet().getName() === 'Sheet1') {
    // Get the exact same range but in Sheet2
    const timespampRange = spreadsheet.getSheetByName('Sheet2')
      .getRange(range.getRow(), range.getColumn(), range.getNumRows(), range.getNumColumns())

    // Set the current datetime to the Sheet2 range
    // The date is on the timezone GTM with the format 2021-03-17T13:03:17Z
    timespampRange.setValue(Utilities.formatDate(new Date(), 'GTM', "yyyy-MM-dd'T'HH:mm:ss'Z'"))
  }
}

You will need to change the timezone to your own and the formatting (as I don't know what you want).

Note that you can add more conditionals on the if statement to add more restrictions (like the number of cells this triggers for).

You may change the names of the sheets but you'll also need to change them on the code. Also, you may protect the timestamp sheet.

References

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM