Macro to randomise names

jwoww

New Member
Joined
May 29, 2021
Messages
22
Office Version
  1. 365
I have a list of competitors that need to be randomly paired up on another sheet to allocate the initial pairings randomly with each other regardless of any other factors.

I would then need a separate function it to be able to randomly pair the names on another sheet based on names that belong to the same group as each other ie. only pair people from group a with people from group a, people from group b with group b etc

Can anyone help suggest where to look to find out how to do this?
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Competition.xlsx
ABCDEFGHI
2Mohamad Al0.830411000116.00101651Normal Class
3Wolfe Glick0.87182100011.001001181Normal Class
4Evgeny Bareev0.54959100010.001000230Great Class
5Dragan Solak0.67759100010.001000230Great Class
6Frank De0.75419100010.001000230Normal Class
7Dustin Zimmerman0.91446100010.001000230Normal Class
8Iván Morovic0.91252100010.001000230Normal Class
9Toler Webb0.18382100010.001000230Master Class
10Li Shilong0.41998100010.001000230Ultra Class
11Ultimo0.07758100010.001000230Master Class
12Jeff Kolenc0.45709100010.001000230Ultra Class
13Alessio Parcianello0.86762100010.001000230Normal Class
14Karuki Ishimaru0.28489100010.001000230Ultra Class
15Martyn Kravtsiv0.14885100010.001000230Master Class
16Brendan Zheng0.53708100010.001000230Great Class
17Ilia Iljiushenok,0.55250100010.001000230Great Class
18Yusup Atabayev,0.52228100010.001000230Great Class
19Hayden Caneron-Jacobus0.19725100010.001000230Master Class
20Kotone Yasue0.94472100010.001000230Normal Class
21Sergey Kudrin0.82499100010.001000230Normal Class
22Nicolas Fotheringham0.14036100010.001000230Master Class
23Sergio Barrientos0.86856100010.001000230Normal Class
Competitors
Cell Formulas
RangeFormula
D2:D23,G2:G23D2=RANK(C2,C$2:C$1213)
E2:E23E2=SUM(SUMIFS(Matches!E:E,Matches!B:B,A2),SUMIFS(Matches!L:L,Matches!I:I,A2))
F2:F23F2=E2+C2
H2:H23H2=SUM(SUMPRODUCT((Matches!B$3:B$31=A2)*(Matches!G$3:G$31>Matches!H$3:H$31)),SUMPRODUCT((Matches!I$3:I$31=A2)*(Matches!G$3:G$31< Matches!H$3:H$31)))
I2:I23I2=CHOOSE(ROUNDUP(RANK(B2,B$2:B$1048576)/$K$2,0),"Normal Class","Great Class","Ultra Class","Master Class")
B2:B23B2=RAND()
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G:GCell ValueduplicatestextNO
H:HCell ValueduplicatestextNO
A2:A1087,A1769:A1048576Cell ValueduplicatestextNO
A2:A100Cell ValueduplicatestextNO
A2:A100Cell ValueduplicatestextNO
 
Upvote 0
A formula approach:

ABCDEFGHI
1Group No1
2Names1Group size (N_1)2Names2Group2Group size (N_2)2
3ABHK1PR
4BIEL2LO
5CJAM1MQ
6DFDN2KN
7ECGO1
8FP1
9GQ2
10HR1
11IS2
12JT2
13U1
14V2
15W1
16X2
17Y2
18Z1
Sheet1
Cell Formulas
RangeFormula
B3:C7B3=LET(c,ROWS(Names1),INDEX(Names1,INDEX(SORTBY(SEQUENCE(c), RANDARRAY(c)),SEQUENCE(c/N_1,N_1))))
H3:I6H3=LET(c,COUNTIF(Group2,I1),INDEX(Names2,INDEX(SORTBY(SEQUENCE(c), RANDARRAY(c)),SEQUENCE(c/N_2,N_2))))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
Group2=Sheet1!$F$3:$F$18H3
N_1=Sheet1!$C$2B3
N_2=Sheet1!$I$2H3
Names1=Sheet1!$A$3:$A$12B3
Names2=Sheet1!$E$3:$E$18H3


Late edit: H3 should be: =LET(c,COUNTIF(Group2,I1),INDEX(FILTER(Names2,Group2=I1),INDEX(SORTBY(SEQUENCE(c), RANDARRAY(c)),SEQUENCE(c/N_2,N_2))))
 
Last edited:
Upvote 0
Hi,

I dont quite understand your formula that you've listed. Are you able to explain it a little bit please?
 
Upvote 0
Here's the first formula. Is it doing what you want?

The second is similar, but first we need to filter by group: The formula in H3 above should have been:

H3:=LET(c,COUNTIF(Group2,I1),INDEX(FILTER(Names2,Group2=I1),INDEX(SORTBY(SEQUENCE(c), RANDARRAY(c)),SEQUENCE(c/N_2,N_2))))

ABC
1
2Names1Group size (N_1)2
3AFJ
4BIE
5CBA
6DGD
7ECH
8F
9G
10HStep 1
11IRandom 1-10
12J7
136
1410
155
169
174
181
193
202
218
22
23Step 2
24Group into pairs
2576
26105
2794
2813
2928
30
31Step 3
32Attach names
33GF
34JE
35ID
36AC
37BH
38
39Step 4
40Put it together
41DI
42AC
43HJ
44EG
45FB
46
47Step 5
48Parameterise
49HG
50AJ
51CE
52IF
53BD
Sheet1
Cell Formulas
RangeFormula
B3:C7B3=LET(c,ROWS(Names1),INDEX(Names1,INDEX(SORTBY(SEQUENCE(c), RANDARRAY(c)),SEQUENCE(c/N_1,N_1))))
B12:B21B12=SORTBY(SEQUENCE(10), RANDARRAY(10))
B25:C29B25=INDEX(B12#,SEQUENCE(5,2))
B33:C37B33=INDEX(Names1,B25#)
B41:C45B41=INDEX(Names1,INDEX(SORTBY(SEQUENCE(10), RANDARRAY(10)),SEQUENCE(5,2)))
B49:C53B49=INDEX(Names1,INDEX(SORTBY(SEQUENCE(ROWS(Names1)), RANDARRAY(ROWS(Names1))),SEQUENCE(ROWS(Names1)/N_1,N_1)))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
N_1=Sheet1!$C$2B3, B49
Names1=Sheet1!$A$3:$A$12B3, B41, B49, B33
 
Upvote 0
Hi,

Thanks for that. I'm not sure if its just because i've been really busy at work and am super tired but it still doesn't make that much sense to me. I think i figured out an alternative that does most of what i want.

Thanks again
 
Upvote 0
I may have misinterpreted what you were asking.

It would be good to see your solution if you care to post it - it may help others looking to create randomised pairings.
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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