30 Advanced Excel Tips for 2026

Excel Champs / Excel Formulas List / How to Generate Random Groups in Excel (Formula)
By Puneet Gogia (Microsoft MVP)

How to Generate Random Groups in Excel (Formula)

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

To assign people to random groups, use =CHOOSE(RANDBETWEEN(1,4),"North","South","East","West") and drag it down your list. RANDBETWEEN picks a number from 1 to 4, and CHOOSE turns that number into a group name.

This is quick, but it won’t give you equal group sizes — you may end up with six people in North and two in West. For equal-sized groups, add a helper column with =RAND(), then use =CHOOSE(ROUNDUP(RANK(B2,$B$2:$B$13)/3,0),"North","South","East","West"), where 3 is the number of people per group.

RANK gives each person a unique position from the random numbers, and dividing by the group size splits them evenly. One thing to watch: RAND and RANDBETWEEN are volatile, so the groups reshuffle every time the sheet recalculates.

Once you’re happy with the result, copy the column and paste it as values (Ctrl+Alt+V → Values) to lock it in. In Excel 365, =SORTBY(A2:A13,RANDARRAY(12)) shuffles the list in one formula, no helper column needed.

  • Random Groups with Random Size (CHOOSE + RANDBETWEEN)
  • Random Groups with Same Size (RAND + ROUNDUP + RANK)

In both methods, we need to write a formula. And in this tutorial, we will learn both ways and understand them in detail.

generate-random-groups

In this example, you have a list of students with their names, and now you need to assign them a random group from north, south, east, and west.

Generating Random Groups in Excel

To write this formula, you can use the below steps:

  1. First, in a cell, enter the CHOOSE function.
  2. And in the first argument of CHOOSE, which is index_num, enter the RANDBETWEEN function.
  3. Now, in the RANDBETWEEN, enter “1” as the bottom and “4” as the top. You have four groups to get the result; that’s why you need to use 1 and 4 to create a range of random numbers.
  4. Next, in the second argument of CHOOSE, enter the name of all four groups by using double quotation marks (“North”,”South”,”East”,”West”).
  5. In the end, hit Enter to get the result. And drag the formula down to the last name.
generate-random-group-in-excel

Note: RANDBETWEEN is a volatile function that updates itself every time the worksheet recalculates (when you change anything or press F9). To keep the groups, copy the results and paste them as values.

=CHOOSE(RANDBETWEEN(1,4),"North","South","East","West")

How this Formula Works

To understand this formula, you need to split it into two parts: In the first part, we have RANDBETWEEN, which returns a random number between 1 and 4 (as we have four groups).

first-part-has-randbetween-function

In the second part, we have the CHOOSE function, which returns a value from the list you define using the index_num. When RANDBETWEEN returns a random number, CHOOSE returns the value from the list using that number.

second-part-has-choose-function

When you have 3 in the index number, CHOOSE returns “East” in the result.

But there’s a Problem.

When you use this formula, there’s no same-size grouping. So, you can see in the result that the groups assigned to the students are not of the same size.

groups-assigned-are-not-of-same-size

This method is only proper when you don’t want to consider the group size; otherwise, you need to use the formula we will discuss next.

Generating Random Groups (Same Size)

To use this formula, you need to create a helper column with the RAND function to get the random number between 0 and 1, just like the following.

generate-random-groups

Note: RAND is also a volatile function that changes its value. And here, I’m going to convert the formula into values.

rand-volatile-function

After that, insert a new column and enter the RANK function. Then, in the number argument, specify the random number from B2; in the ref argument, use the entire range of random numbers.

entire-range-of-random-numbers
=RANK(B2,$B$2:$B$13)

It creates a unique ranking for all the 12 students you have on the list. Now, you need to divide this ranking by three, as you need to have three students in a single group.

creates-a-unique-ranking
=RANK(B2,$B$2:$B$13)/3

Next, you need to use the ROUNDUP to round these rankings upwards.

roundup-to-round-ranking-upwards
=ROUNDUP(RANK(B2,$B$2:$B$13)/3,0)

After using ROUNDUP, you get an even size group where each group has the same number of students (12 students in the four groups with three students in each group). Then, again, use the CHOOSE to convert these number groups into group names.

even-size-group
=CHOOSE(ROUNDUP(RANK(B2,$B$2:$B$13)/3,0),"North","South","East","West")

As the ranks run from 1 to 12, dividing by 3 and rounding up gives 1 for ranks 1-3, 2 for ranks 4-6, and so on, so each group gets exactly three students.

Random Groups of Any Size

The formula above has 3 (students per group) and the four group names typed into it. To make it work for any list, put the group names in a range (like E1:E4) and the number of groups in a cell (like G1). The formula below works out the group size from the number of names and picks the group name with INDEX:

=INDEX($E$1:$E$4,ROUNDUP(RANK(B2,$B$2:$B$13)/(ROWS($B$2:$B$13)/$G$1),0))

If the number of students can’t be divided equally (like 13 students in 4 groups), some groups get one more student than the others, but the sizes stay as close as possible.

Random Groups with Dynamic Arrays

In Microsoft 365, you can do it without a helper column. SORTBY with RANDARRAY shuffles the names, and WRAPCOLS splits the shuffled list into columns of three, so each column is a group:

=WRAPCOLS(SORTBY(A2:A13,RANDARRAY(ROWS(A2:A13))),3)

Like RAND, this formula changes every time the sheet recalculates, so paste the result as values once you’re happy with the groups.

Frequently Asked Questions

How do I stop the groups from changing?

Copy the cells with the groups (and the random numbers) and paste them as values (Ctrl + Alt + V, then V). After that, the formulas are gone, and the groups stay as they are.

Can two students get the same rank?

Only if RAND returns exactly the same number twice, which is extremely unlikely. If it ever happens, press F9 to get new random numbers.

How do I make groups of a fixed number of students?

Divide the rank by the group size you want, like /5 for groups of five, and round up. The result is the group number (1, 2, 3 and so on), which you can use as it is or turn into a name with INDEX.

Puneet Gogia

Written by

Puneet Gogia

Microsoft MVP — Excel · Founder, Excel Champs

Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel

Leave a Comment