0
votes

Is it possible to format a cell (set the background color, for instance) based on the user currently viewing the sheet?

I'm using Google Sheets for an employee scheduling application and would like to highlight the name of the employee currently viewing the sheet everywhere that name appears on the schedule.

So if Tom opens the sheet, all cells with "Tom" in them would appear highlighted. If Bob opens the same sheet, all cells with "Bob" in them would appear highlighted.

Thanks in advance!

2

2 Answers

2
votes

According to Google Apps Script:

getActiveUser()

Gets information about the current user. Returns a User object describing the current user. In limited-privilege executions (such as in response to onOpen or onEdit events), we only return the identity of the active user if both the user and the script owner are part of the same domain. This is to protect the privacy of consumer users, who may not want their email address exposed. For more information, see the active user entry in the Glossary.

So if you have someone using the spreadsheet from within your domain (for business, education), then you could have an onOpen script and attempt a filter/highlight function based on your parameters and script.

Cheers!

0
votes

You could create specific filter views for your team. Select Data > Filter Views and name your filter view after the teammate. Filter views allow different people to view the same sheet differently. I may be wrong about this, but I don't believe there is a way to turn the filter views on and off programmatically through GAS, but each filter view has a unique URL, so you could use getActiveUser() in conjunction with an alert prompt linking the active user to their personal filter view.