I'm working on spreadsheet with table that contains names of workers and their availability during whole year. My goal is to highlight cell with proper name when specific person opens the sheet. All users have their google mail in [email protected] schema.
I've already made some code which find name and do bold action on active user's name, you can see it below:
function onOpen(e)
{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
for(var k = 0; k<sheets.length; k++)
{
var data = sheets[k].getDataRange().getValues();
var user = Session.getActiveUser().getEmail();
var splitname = user.split("@")[0];
var first = splitname.split(".")[0];
var last = splitname.split(".")[1];
var formatted_first = first.charAt(0).toUpperCase() + first.slice(1);
var formatted_last = last.charAt(0).toUpperCase() + last.slice(1);
var name = formatted_first + " " + formatted_last;
for(var i = 0; i<data.length;i++)
{
if(data[i][0] == name)
{
var a = i+1;
}
}
sheets[k].getRange(a,1).setFontWeight("bold");
}
}
The problem is that:
- I don't know how to perform an action temporarily, only for time when sheets is open.
- After writing code I realized that bold action will be visible for all active users, so if one user opens the sheet when the other has it already open and not close yet, he will see not only his name highlighted but also that other user's name.
Soo, my question is whether there is any possibility to make changes visible only for user that made them and how to perform the highlighting only while sheet is open.
If you know any google feature which makes it possible without using the macro, it would be the best solution. Maybe my research wasn't good enough.
Thank you in advance for help!
FilterViews
. Consider using them, or a sidebar that allows the user to click a link to set the active cell to the one that is pertinent to their work. – tehhowch