Function needed to remove duplicates from index(randbetween(counta formula

andrew_milonavic

Board Regular
Joined
Nov 16, 2016
Messages
98
Hi,

I'm using this formula: =IFERROR(INDEX(A$3:A$30,RANDBETWEEN(1,COUNTA(A$3:A$30)),1),"") to randomly select 4 options from a list. Results are in cells A34-A37 and I would like to have no duplicates. Possible?

Thanks

Andrew
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
1. In A3:A30 place your data (that's 28 items).
2. in B3:B30 put =RAND()
3. in C3:C30 put
either
=INDEX(A$3:A$30,MATCH(SMALL(B$3:B$30,ROW()),B$3:B$30,0))
or
=INDEX(A$3:A$30,RANK(B1,$B$3:$B$30),1)

This will pick ALL of the random items without producing duplicates
Then just use the values in C1 C2 C3 C4 if you want 4 random items without duplicates

in A34
=C1
and copy down until A37
 
Last edited:
Upvote 0
Assuming that whatever is in A33 is not in the A3:A30 list, then put this formula in A34, then drag down to A37:

=IFERROR(INDEX($A$3:$A$30,AGGREGATE(15,6,(ROW($A$3:$A$33)-ROW($A$3)+1)/(($A$3:$A$30<>"")*(COUNTIF($A$33:$A34,$A$3:$A$30)=0)),RANDBETWEEN(1,COUNTA($A$3:$A$30)-ROWS($A$34:$A35)+1))),"")
 
Last edited:
Upvote 0
Hey Eric,

Array version worked perfectly. I'll likely stick with it, but I'll copy the non array version as well to play with at a later date.

I really appreciate your help!!!

Thanks

Andrew
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,148
Members
453,021
Latest member
Justyna P

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