1
votes

I hope you're all doing well.

I have this script in my Google sheet:

function onEdit() {
  var s = SpreadsheetApp.getActiveSheet();
  if( s.getName() == "Sheet1" ) { 
    var r = s.getActiveCell();
    if( r.getColumn() == 3 ||r.getColumn() == 5||r.getColumn() == 7) {
      var nextCell = r.offset(0, 1);
      nextCell.setValue(new Date());
    }
  }
}

Whenever you enter a value or text in columns 3, 5 or 7, the cell next to each column will be filled with a date. My question is how do I make it so that the date will only appear in column 9 instead of 4, 6 and 8.

Here's my sheet: https://docs.google.com/spreadsheets/d/1vxG-NWVYFOch7YvEo3PnTdYwFFCqWyw2Il9C2TEi8q8/edit?usp=sharing

1

1 Answers

2
votes

Change this line

var nextCell = r.offset(0, 1);

to

var nextCell = s.getRange(r.getRow(), 9);

and see if that works?