Choose 2 items randomly from list - no duplcates

henryg

Board Regular
Joined
Oct 23, 2008
Messages
143
Office Version
  1. 365
Platform
  1. Windows
I want to select two items randomly from a (shortish) list with no duplicates.

To select one item I used

=INDEX(B$18:B$29,RANDBETWEEN(1,COUNTA(B$18:B$29)))

but when I copy this down to get a second value, as the list is relatively short, I get duplicates.

I tried using IF but couldn't see a way to get the second value to recalculate until it was unique. So I tried UNIQUE too, but still couldn't find a solution.

Anyone, please.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
How about
+Fluff v2.xlsm
BCDE
18Ullswater2Penzance East
19Cleobury MortimerCleobury Mortimer
20Todmorden
21Penzance Central
22Penzance East
23St Ives West
24Camborne Roskear
25Four Lanes
26Redruth North
27Constantine, Mawnan and Budock
28Newquay Central
29Ladock, St Clement and St Erme
30
Main
Cell Formulas
RangeFormula
E18:E19E18=INDEX(SORTBY(B18:B29,RANDARRAY(ROWS(B18:B29))),SEQUENCE(D18))
Dynamic array formulas.
 
Upvote 0
Thank you. Rows() instead of Counta(), ok; Sequence() I get; but I need to get my head around what Sortby() and Randarray() are doing in combination :cool:

But I just knew the solution would be a spilled array ;)
 
Upvote 0
The Randarray creates an array of (in this case) 12 numbers & the sortby then sorts the values in col B based on the random numbers.
So it's basically shuffling the values.
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top