Get user input to use in an Excel Online Script

New Contributor

Hi

 

Does anyone know if it's possible to get user input to use as a variable with Excel Online Scripts?

 

I have hundreds of people using a workbook online and need to use their username to filter rows from clicking a button.

 

At the moment they have to type their username into a cell and the script will get that number, put it in a var (while replacing the cell contents with a blank, so that someone else can run the script).

 

Or, can the Excel Online Script access the username of the person that is using the excel online workbook?

 

Thanks,

Matt

2 Replies
Perhaps you can write a do-while type of loop which waits for an entry in that cell. Place the username cell on a separate tab and have the script activate that tab and clear the cell. Then start the waiting loop using code as mentioned here (not sure if that'll work in Office Script though): https://stackoverflow.com/questions/5551378/javascript-pausing-execution-of-function-to-wait-for-use...
Alternatively, have the script clear the username cell at the end.
Place a button next to that cell that triggers the script. The script checks if the cell contains something and if so, assumes the entry is the username. If the cell is empty, the script selects the cell, perhaps writes a prompt in the cell above it and ends.