Single formula to randomly shuffle the rows of an Excel range
Syntax: =\SHUFFLE.ROWS(range) => array
=LAMBDA(range,
LET(
rw,ROWS(range),
TAKE(
SORT(
HSTACK(
MAP(SEQUENCE(rw,1,0,0),
LAMBDA(x,RAND())
),
range
),
1
),
rw,
-COLUMNS(range)
)
)
)
Documentation
Returns the source range or array with rows in random order.
This function is based on the Excel RAND() function, and therefore is volatile – the output will change order on each recalculation.
Commentary
This does literally the same exact thing a user would do to shuffle a range:
- Add first column with random numbers
- Sort by first column
- Remove first column