Random Selection Without Repeats (Shuffle)

Excel Formulas › Math

Excel 365Legacy alt

Picking random names without picking the same one twice — a raffle, a shuffled order, random team assignment — needs sampling without replacement. In Excel 365, SORTBY + RANDARRAY shuffles a list in one formula.


Quick formula: to shuffle a list into random order (Excel 365):
=SORTBY(A2:A20, RANDARRAY(ROWS(A2:A20)))
RANDARRAY gives each row a random sort key; SORTBY reorders the list by those keys — a true shuffle with no repeats. Take the top N for a random sample.

Functions used (tap for the full reference guide):

The example

A name list shuffled into a random order (no name repeats).

AC
1NamesShuffled
2AnaCy
3BenAna
4CyDot
5DotBen

The formula

The shuffled list:

=SORTBY(A2:A5, RANDARRAY(ROWS(A2:A5))) // random order, each name once

How it works

Sort by a random key to shuffle:

  1. RANDARRAY(ROWS(A2:A5)) generates one random number per name — a random sort key for each row.
  2. SORTBY(A2:A5, …) reorders the names by those random keys, producing a shuffle.
  3. Because it’s a reorder of the original list, no name repeats — that’s sampling without replacement.
  4. For a random sample of N, wrap in TAKE(…, N) or just read the top N rows of the shuffle.

Pre-365? Add a helper column of =RAND(), then sort the list by that column — or use =INDEX(list, RANK(RAND(), randColumn)). The SORTBY approach just does it in one cell.

Try it: interactive demo

Live demo

Shuffle the list (no repeats) — click to reshuffle.

Order:

Variations

Random sample of N

Take the top N of the shuffle:

=TAKE(SORTBY(A2:A100, RANDARRAY(ROWS(A2:A100))), 5)

Legacy helper-column shuffle

Add =RAND() beside the list and sort by it.

Random unique numbers

Shuffle a sequence:

=SORTBY(SEQUENCE(50), RANDARRAY(50))

Pitfalls & errors

It reshuffles on every recalc. Like all random formulas, the order changes constantly. Paste Special → Values to freeze a draw.

Excel 365 for the one-formula version. SORTBY/RANDARRAY need 365/2021. Older Excel uses the RAND helper-column method.

Ties are astronomically unlikely with RANDARRAY, but on tiny lists a repeated key could occur — harmless, it just keeps original order for the tie.

Practice workbook

📊
Download the free Random Selection Without Repeats (Shuffle) practice workbook
A name list shuffled with SORTBY+RANDARRAY (result shown), the sample-of-N and legacy helper-column variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I randomly shuffle a list in Excel?
In Excel 365 use =SORTBY(range, RANDARRAY(ROWS(range))). RANDARRAY assigns a random key to each row and SORTBY reorders by it, with no repeats.
How do I pick N random items without duplicates?
Take the top N of a shuffle: =TAKE(SORTBY(range, RANDARRAY(ROWS(range))), N).
How do I shuffle without Excel 365?
Add a helper column of =RAND() next to the list and sort the list by that column, or use INDEX with RANK of the random values.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Generate random numbers · Sort by multiple columns · Generate numbers with SEQUENCE

Function references: SORTBY · RANDARRAY · RANK