Forum Discussion
archifaust
Mar 02, 2024Copper Contributor
RANDARRAY with equal spread of numbers
I need to generate a RANDARRAY that is 17 rows and 14 columns using only numbers 1 thru 5... I can do this using =RANDARRAY(17, 14, 1, 5, TRUE) but I need it to generate with a near equal number of e...
djclements
Mar 02, 2024Silver Contributor
archifaust Perhaps something like this:
=WRAPROWS(TAKE(SORTBY(TOCOL(IF(SEQUENCE(48), SEQUENCE(,5))), RANDARRAY(240)), 238), 14)
The TOCOL / IF / SEQUENCE combo is used to repeat numbers 1 thru 5, 48 times, in a single column. SORTBY is used to randomize the results with the RANDARRAY function, then TAKE ensures the correct number of items are passed to the WRAPROWS function to generate the 17x14 array.