0

I am trying to work out what script is required to have multiple timestamps on several tabs however each one I have tried doesn't work for me. I am new to this.

When text is added to column 2 I need a timestamp in column 1. When text added in 8 I need a timestamp in 7. When 15 which is a checkbox, a timestamp in 16, and when 18, timestamp in 17. Is this possible to have so many?

My current script is as follows and this is giving me the time stamp in column 1 when column 2 is amended and it doesnt overwrite when it is changed a second time.

function onEdit(e) {
  var row = e.range.getRow();
  var col = e.range.getColumn();
  if (col === 2 && row > 1 && e.source.getActiveSheet().getName() === "June 2021") {
    if (e.source.getActiveSheet().getRange(row, 1).getValue() == "") {
      e.source.getActiveSheet().getRange(row, 1).setValue(new Date());
    }
  }
}
5
  • Welcome to Web Applications. Please add more details including what you tried and a brief but specific description of your search efforts as is suggested in How to Ask. – Rubén May 30 at 23:26
  • Hi Ruben I have added my current script. I have searched the other similar questions on this site and tried different scripts of tweaking this but i cannot make anything work? – Sophie May 31 at 8:16
  • Consider sharing a publicly editable sample spreadsheet with realistic-looking data, and showing your hand-entered expected results there. Use Insert > Note to describe what you want in the spreadsheet. – doubleunary May 31 at 9:18
  • Sophie: It's recommended to include links to at least one of the posts that have been reviewed. Anyway, I think that you should spend some time learning the JavaScript basics in order to be able to better adapt the scripts that you might find on the web to your specific cases. An onEdit simple trigger is ran when any range from bounded spreadsheet edited. You might control when a change is made over the spreadsheet by using JavaScript statements with expressions. The if statement is one of the most commonly used but it also could be done with other statements like switch. – Rubén May 31 at 15:10
  • Related 1, Related 2 – Rubén May 31 at 15:13
0

A single onEdit(e) function can watch multiple columns on multiple sheets and insert timestamps in multiple columns depending on which column was edited and what the new value in the cell is. See the timestampMultipleColumns_ script for an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.