2

I need timestamps on two different sheets to make two different dependent drop boxes work. I use the scripts below but can only get one sheet to work and not both sheets:

Script time in

function onEdit(event) {

  //SETTINGS
  var tsheet = 'In';
  var lcol = 2;
  var rcol = 8;
  var tcol = 9;
  //

  var s = event.source.getActiveSheet();
  var sname = s.getName();
  if (sname == 'In') {
    var r = event.source.getActiveRange();
    var scol = r.getColumn();
    if (scol>= lcol<=rcol) {
      s.getRange(r.getRow(), tcol).setValue(new Date());
    }
  }
}

Script Time out

function onEdit(event) {

  //SETTINGS
  var tsheet = 'Out';
  var lcol = 2;
  var rcol = 8;
  var tcol = 9;
  //

  var s = event.source.getActiveSheet();
  var sname = s.getName();
  if (sname == 'Out') {
    var r = event.source.getActiveRange();
    var scol = r.getColumn();
    if (scol>= lcol<=rcol) {
      s.getRange(r.getRow(), tcol).setValue(new Date());
    }
  }
}
  • Common practice is to marked the answer as best answered. Read our help center or take the tour to know more about that. Welcome to Web Applications !! – Jacob Jan Tuinstra Mar 18 '15 at 8:45
2

Having two onEdit scripts isn't gonna work. So try to merge the two scripts into one...

function onEdit(e) {
var s = e.source.getActiveSheet(),
    sheets = ['In', 'Out'],
    ind = sheets.indexOf(s.getName());
    if (ind === -1 || e.range.columnStart < 2 || e.range.columnStart > 8) return;
e.range.offset(0, 9 - e.range.columnStart)
    .setValue(new Date())
}

.. and see if that works ?

  • 1
    JPV, it works brilliantly! Really appreciate your help, after trying to figure it out myself for 2 days:) Thanks Jeroen – Jeroen Schedler Mar 15 '15 at 23:11

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.