1

This question already has an answer here:

In Google Spreadsheets, is there a simpler way to put the edited date of a cell into another cell?

I've set a data validation list:

  • ACTIVE
  • COMPLETED
  • ONHOLD
  • TESTING
  • BUGFIXING

to F column. If the value of F column is changed to ACTIVE, the value of corresponding G column cell should be that date.

marked as duplicate by Vidar S. Ramdal, jonsca Mar 11 '15 at 23:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

With the following little script you can do that.

Code

function onEdit(e) {
  var r = e.range, c = r.getColumn(), v = e.value;
  if(v == "ACTIVE" && c == 6) {
    r.offset(0, 1).setValue(new Date);    
  }
}

Explained

The onEdit trigger is only fired if column F is selected (c == 6) and if the value of the list is (changed to) ACTIVE (v == "ACTIVE"). After that it will change the range one column length (r.offset(0, 1)) and add the date.

Example

I've created an example file for you: Add date to adjoining column
Add the script via Tools > Script editor, press the save button and you're on the go.

  • It worked, How to set the value in previous column's cell – tvshajeer Mar 11 '15 at 10:07
  • 1
    @tvshajeer Then use this instead: r.offset(0, -1).setValue(new Date); – Jacob Jan Tuinstra Mar 11 '15 at 10:34

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