Home > Software design >  Sheets multiple random numbers in range
Sheets multiple random numbers in range

Time:10-07

I'm making a fairly simple spreadsheet to organize a tournament of sorts and wanted to find a way to randomize some variables using sheets.

The idea is that there are 25 possible maps which can be chosen, but the user will determine how many maps will be played (within the sheet), for example 5. Ideally I'd have a cell which would take the number of maps to be played (in this case 5) and will then print the 5 random maps in sequence from the range of map 1, to map 25.

Eg -

D24 = 5 (Number of maps)

D26 = 3,16,21,13,6

Would there also be a way to have it so no duplicates can occur?

I tried something like this: =TRUNC(RAND() * (25-1) 1) however couldn't find a way to make it loop.

CodePudding user response:

Try:

=JOIN(", ", ARRAY_CONSTRAIN(SORT({A2:A26, RANDARRAY(COUNTA(A2:A26), 1)}, 2, 1), D2, 1))

enter image description here

  • Related