How to Randomly Select a Name and Assign a Role Using Excel Formulas
Question details
The user needs an Excel formula to randomly pick a name from a predefined list and assign a specific role to that selected individual.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Assigning random roles to individuals in a list for daily tasks, games, or shift rotations.
- Observed behavior
- Requires a dynamic formula-based solution to pull a random name from a cell range and pair it with a randomly selected role.
Ensure your list of names is organized in a single column without empty cells in between, as blank cells can cause the counting formula to work inaccurately.
Use INDEX and RANDBETWEEN Formulas
Combine the INDEX, RANDBETWEEN, and COUNTA functions to randomly pull a name from your list and assign a role.
This method leverages Excel's native randomization and lookup functions. Keep in mind that volatile functions like RANDBETWEEN will recalculate automatically every time you make a change to the spreadsheet, generating a new random result.
Enter your list of names in a single column, for example, from cell A2 to A10.
In an empty cell where you want the name to appear, enter the formula =INDEX($A$2:$A$10,RANDBETWEEN(1,COUNTA($A$2:$A$10))) and press Enter.
In the adjacent cell, type =INDEX({"Role 1","Role 2"},RANDBETWEEN(1,2)) to randomly assign one of the two roles to the selected name.
Since the formulas recalculate automatically, you can copy the resulting cells (Ctrl+C) and paste them as values (Ctrl+Shift+V) to lock the random assignment permanently.

Use WPS Spreadsheet to Randomly Assign Roles
WPS Office Spreadsheet fully supports advanced array formulas like INDEX and RANDBETWEEN. You can easily manage lists, randomize names, and assign roles without compatibility issues.
- 1. Open WPS Spreadsheet: Launch WPS Office and open a new or existing spreadsheet containing your list of names.
- 2. Input the randomization formulas: Select an empty cell and input your =INDEX(...) and =RANDBETWEEN(...) formulas exactly as you would in Excel.
- 3. Calculate and save: Press Enter to generate the random results, and save your workbook in .xlsx format for seamless cross-platform compatibility.

Frequently Asked Questions
How can I stop the random names from changing every time I type?
Formulas using RANDBETWEEN recalculate upon any worksheet change. To stop this, select the cells displaying the random results, copy them (Ctrl+C), right-click, and choose 'Paste as Values' to replace the formulas with static text.
Can I assign more than two roles using this formula?
Yes. Just add more roles to the array inside the curly brackets and increase the upper limit in the RANDBETWEEN function accordingly. For example: =INDEX({"Role 1","Role 2","Role 3"},RANDBETWEEN(1,3)).
What if my list of names contains blank cells?
If there are blank cells within your range, the COUNTA function might return a lower number than the actual range size, leading to #REF! errors. It is best to remove blank cells or use a fixed upper number in the RANDBETWEEN function instead of COUNTA.
Is it possible to ensure a name isn't selected twice if I drag the formula down?
The basic RANDBETWEEN formula can produce duplicates because each cell calculates independently. To prevent duplicates, assign a random number (using the =RAND() formula) in a column next to your names, sort the list by those random numbers, and then assign roles in sequential order.




