1

This is what I use to allow Google Sheets to auto-populate the date/time in column "N" whenever any cell in that row is updated.

function onEdit() {
  var s = SpreadsheetApp.getActiveSheet();
  var r = s.getActiveCell();
  if( r.getColumn() != 8 ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT-04:00", "MMM/dd/yy, hh:mm:ss");
    SpreadsheetApp.getActiveSheet().getRange('N' + row.toString()).setValue(time);
  };
 }

I want to be able to auto populate the Google user/name who made an any changes when a cell in that row is updated.

Is this possible?

-1
function onEdit() {
  var s = SpreadsheetApp.getActiveSheet();
  var r = s.getActiveCell();
  if( r.getColumn() != 8 ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT-04:00", "MMM/dd/yy, hh:mm:ss");

    // call function below to get user email - send var s as parameter
    // this way you avoid to call getactivesheet again
    getUser(s)

    //how do you plan to set email (return from getUser) value in sheet?
    //try to create an Array to store time, email and aby other data you want to save in sheet
    // and use only one set command - set and get commands decreases performance
    //exemple: setValues([dataToRng])
    //has to use brackets [...] as dataToRng is an Array
    //atention! setValues needs an Array of 2d (row, column)
    SpreadsheetApp.getActiveSheet().getRange('N' + row.toString()).setValue(time);

    //below a sugestion to best performance
    //this way you avoid to call getactivesheet again  
    //s.getRange('N' + row.toString()).setValue(time);    

  };
 }


function getUser(s) { 
 var email = Session.getActiveUser().getEmail();
 Logger.log(email);     // only to check, can be deleted
 return email;
}
  • The question doesn't mention if a simple or an installable trigger is being proposed. – Rubén Aug 27 '16 at 19:24

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