Rand Between Multiple Lists With No Duplicates

andrew_milonavic

Board Regular
Joined
Nov 16, 2016
Messages
98
Hi,

I have several lists in columns A through F and at the bottom of each column I'm using this formula: =IFERROR(INDEX(A$1:A$100,RANDBETWEEN(1,COUNTA(A$1:A$100)),1),"") to randomly select from the column list. If the lists has duplicates, which it does by design, how can I keep it from returning duplicates (matching another column)?

Example: If "Cat" is in column A and column B, how do I keep the results from being "Cat" in both columns.

Would prefer a formula solution instead of Macro.

Thanks

Andrew
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try:

Book1 (version 1).xlsb
ABCDEF
1List1List2List3List4List5List6
2CatChihuahuaDogAlpacaZebraLynx
3DogSalmonMouseBearYakSalmon
4IguanaParrotParrotCatCatMouse
5ParrotOwlGiraffeDingoWolfNarwhale
6SharkMouseDragonElephantTigerOwl
7ElephantBearFoxSalmonParrot
8TroutGorilla
9Hare
10
11
12
13
99
100
101TroutParrotMouseElephantZebraSalmon
Sheet10
Cell Formulas
RangeFormula
A101A101=IFERROR(INDEX(A$1:A$100,RANDBETWEEN(1,COUNTA(A$1:A$100)),1),"")
B101:F101B101=IFERROR(INDEX(B:B,AGGREGATE(15,6,ROW(B$2:B$100)/(COUNTIF($A101:A101,B$2:B$100)=0)/(B$2:B$100<>""),RANDBETWEEN(1,SUMPRODUCT(--(B$2:B$100<>""),--(COUNTIF($A101:A101,B$2:B$100)=0))))),"")


Put your original formula in A101, then put the B101 formula in and drag to the right.
 
Upvote 0
Thanks @Eric W ,

That works perfectly! Greatly appreciated.

As a follow up, is there a way to specify columns? Say I wanted no duplicates in just columns A,C,E?

Thanks

Andrew
 
Upvote 0
Possible, but it depends on what you want. As described, you could just put your old formula in A,B,D, and F, and the new one in C and E.
 
Upvote 0
Thanks Eric,

I think I can make it work with what you've suggested and I've played around with your provided formula so I'm pretty sure I can adapt it when I expand the lists and various combinations.

Thanks again, greatly appreciated.

Andrew
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,094
Latest member
bsb1122

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