I want to get the active user’s email address and put it directly into a specific cell in my Google Sheets document. My goal is to use this email for a lookup function later.
I already created a Google Apps Script that can get the current user information and it works fine when I check the logs. However, I can’t figure out how to take that user data from the script and actually write it into a cell on my spreadsheet.
Is there a way to automatically populate a cell with the current user’s email address using Apps Script? I need this to work so I can reference that cell in other formulas.
just use getRange().setValue(). like this: SpreadsheetApp.getActiveSheet().getRange('A1').setValue(Session.getActiveUser().getEmail()). make sure your script has the right permissions tho!
You can use setValue() in Google Apps Script to put the logged-in user’s email into any cell. First, grab the email with Session.getActiveUser().getEmail(). Then get your sheet using SpreadsheetApp.getActiveSheet(). Use getRange() to pick your cell and call setValue() with the email. So for cell A1, you’d write sheet.getRange('A1').setValue(userEmail). Just make sure your script has permission to access user data or it won’t work.