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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,214,561
Messages
6,120,242
Members
448,951
Latest member
jennlynn

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