A51himself
A51himself

Reputation: 119

Google sheets current user

I'm looking to display the current user of a google sheet in a cell to pull a vlookup off,

I have added a script to pull the logged in username into a script gallery but I am unable to dump the logger.log information into a google sheet

Upvotes: 10

Views: 27860

Answers (1)

Justin Kaese
Justin Kaese

Reputation: 321

This works fine :) remember how to use getRange(row,column) as it will be your best friend now you are scripting..

function setActiveUser() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();

  // GET EMAIL ADDRESS OF ACTIVE USER
  var email = Session.getActiveUser().getEmail();
  Logger.log(email);

  //SET CELL A1 TO EMAIL ADDRESS OF ACTIVE USER
  sheet.getRange(1,1).setValue(email);
}

Upvotes: 17

Related Questions