0

I am trying to enter a timestamp in google script for a google sheet with date/time & user in columns 14 (data entry) and 15 (last modification) with some conditions (the most important is data in column 4). This works fine for data entered manually cell by cell but not if you will copy it (most probably columns 2-7). I tried but couldn't solve it so far. Any idea how to solve it? Let me know if there are any questions.


function onEdit(e)
{
 timestamp(e);


}




function timestamp (e)

{
  //Variablen
  var startRow = 2;
  var targetColumn = 4;
  var ws = "ACTION";


  var row = e.range.getRow();
  var col = e.range.getColumn();
  var rangeRowEnd = row + range.getHeight();

   e.source.getActiveSheet().getRange(row,17).setValue(rangeRowEnd);


    if(col === targetColumn && row >= startRow && e.source.getActiveSheet().getName() === ws) {
      var currentDate = Utilities.formatDate(new Date(), "GMT+0100", "dd.MM.yyyy HH:mm:ss");
      var user = Session.getEffectiveUser();
      //var sA   = e.range.getValues();//get all values in range

      for(var i=0;i<rangeRowEnd;i++) {
         e.range.getSheet().getRange(e.range.rowStart+i,15).setValue("'" + currentDate+ " "+ user);
           if(e.source.getActiveSheet().getRange(row,14).getValue() == "") {
           e.source.getActiveSheet().getRange(row,14).setValue("'" + currentDate+ " "+ user);
           } // End if "Date modified"

      } // End for 




    } // End if "Date entered"

} //End fuction

Your Answer

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

Browse other questions tagged or ask your own question.