\SHUFFLE.ROWS

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:

  1. Add first column with random numbers
  2. Sort by first column
  3. Remove first column

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top