Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google sheets current user

I was hoping you could help me,

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

Any information would be great,

thank you Nigel

like image 630
A51himself Avatar asked Sep 01 '15 14:09

A51himself


People also ask

How do I see users in Google Sheets?

At the top of the Users list, click Download users. Choose to download a filtered list or a list of all users. Choose to include only the columns displayed in the Users list or all available columns in the downloaded file. Choose to download the users list as a CSV file or export it to Google Sheets.


1 Answers

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);
}
like image 182
Justin Kaese Avatar answered Sep 29 '22 12:09

Justin Kaese