Formula help; Randomly display names from list no duplicates until you have to

Tardisgx

Board Regular
Joined
May 10, 2018
Messages
81
tables.PNG

In the following context when I say randomly it means in a random order so every recalculate could move the results around.

In this example I am trying to randomly display these 3 colours without duplicating, e.g no red, red, red or red blue red

=INDEX(Table16[colours],MATCH(SMALL([Column1],ROW()-1),[Column1],0))

The above formula only works for 3 rows then gets a ref error.

What I need is for the output to behave exactly like it is doing and repeat itself for the rows thereafter.

So if I had 3 colours and there were 6 rows to populate I would want each colour to appear twice exactly but randomly.

If I had 3 colours and there were 12 rows to populate I would want each colour to appear 4 times exactly but randomly.

If I had 3 colours and there were 13 rows to populate I would want 2 colours to appear 4 times and 1 to appear 5.

If I had 3 colours and there were 2 rows to populate I would want 2 colours to appear once each.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I figure the easiest way is to copy the table (with formulas) without headers and put it under the original table. That'll be random and fair.

Then I can vlookup results on based on row number.

Think I'll write some VBA to automate copying the table so I don't have to do that manually.
 
Upvote 0
Book1
DEFG
1ColorsData
2blueblue
3redgreen
4greenred
5green
6blue
Sheet1
Cell Formulas
RangeFormula
G2:G6G2=INDEX(Table1[Colors],AGGREGATE(15,6,ROW(Table1)/(COUNTIFS(G$1:G1,Table1[Colors])<INT((ROWS(G$2:G2)-1)/ROWS(Table1)+1)),RANDBETWEEN(1,ROWS(Table1)-MOD(ROWS(G$2:G2)-1,ROWS(Table1))))-ROW(Table1[#Headers]))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
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