Creating exception to random Team generator

paulgunther

New Member
Joined
Oct 30, 2019
Messages
31
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet that assigns players to random holes (Start) based on a chosen number of players per card (I3). It's fairly simple and I also have a macro assigned to a button that copies the "random" column and pastes values to the "static" column to re-randomize at will. The "hole_assignment" table is to assign the holes in a specific, non-sequential order. This works fine as designed.

Question: I would like to occasionally assign certain players to specific holes (column A) and have the Start column account for the pre-assigned starting hole and randomize the rest.

Example: Player 2, pre-assigned hole 8, Player 6 pre-assigned hole 8. I now need the randomizer to only assign 2 additional players to hole 8 and automatically place those players on their respective pre-assigned holes.

Random Card.xlsm
ABCDEFGHI
1
2Non RandomCardPlayerStartGroupRandomStatic
3Player 1270.2263043540.262627438Card Size4
48Player 2820.3879379380.796961803
5Player 31030.6701634850.68759244CardAssigned Hole
6Player 4460.5389380970.35194473911
7Player 51030.6408439280.74684021828
88Player 61030.8737932760.75425269310
9Player 71240.5654047050.627886504412
10Player 8110.4988491780.87951887256
11Player 99100.0932334210.04976329364
12Player 101390.797314870.09855282472
13Player 11110.6819009280.889456719811
14Player 12650.7408938520.569148347913
15Player 13110.340686960.865395664109
16Player 14460.9233135340.369695062113
17Player 151390.7531950940.13534933127
18Player 161180.8870338330.2111415521318
19Player 17460.6603175250.517424354145
20Player 18650.7532726010.554959501
21Player 19650.5153775270.524942895
22Player 201180.2742464570.256438207
23Player 211390.4251237450.149393574
24Player 229100.631862220.026967303
25Player 239100.341396670.096754073
26Player 24460.8051692220.388082165
27Player 251240.4998070020.615633054
28Player 261180.7721284090.217260568
29Player 27270.723632090.292360797
30Player 28110.167612520.905538699
31Player 29270.4967091590.270637506
32Player 30650.1722856520.564299634
33Player 31270.1871673010.261168275
34Player 32820.4636778770.784721414
35Player 33820.3399543980.782527076
36Player 34820.5471294770.796425025
37Player 351180.3305127370.201663754
38Player 361030.7042708740.764741023
39Player 371240.1209793360.597508326
40Player 381240.620319410.639348663
41Player 391390.9444481480.195836014
42Player 409100.7291462530.047685875
WORKING
Cell Formulas
RangeFormula
C3:C42C3=VLOOKUP([@Group],Hole_Assignment,2)
D3:D42D3=CEILING(RANK([@Static],[Static])/$I$3,1)
E3:F42E3=RAND()
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A3:A42Expression=COUNTIF($A$3:$A$42, A3) = 2textNO
A3:A42Expression=COUNTIF($A$3:$A$42, A3) = 3textNO
A3:A42Expression=COUNTIF($A$3:$A$42, A3) = 4textNO
C3:C42Expression=COUNTIF($C$3:$C$42, C3) = 2textNO
C3:C42Expression=COUNTIF($C$3:$C$42, C3) = 3textNO
C3:C42Expression=COUNTIF($C$3:$C$42, C3) = 4textNO
C3:C42Expression=COUNTIF($C$3:$C$42, C3) = 5textNO
C3:C42Expression=COUNTIF($C$3:$C$42, C3) > 5textNO
B3:B42Cell ValueduplicatestextNO
Cells with Data Validation
CellAllowCriteria
B2Any value
C3:D42Any value
 
Also if you are happy converting your table into a normal range you could use
Fluff.xlsm
IJKLMNOP
1
2Non RandomCardPlayerStartRandomStatic
3Card Size4Player 140.0333450.505865
48Player 280.0698290.474071
5CardAssigned HolePlayer 390.6191760.011008
611Player 440.6001870.447861
728Player 5110.1671490.149915
83108Player 680.9859880.235066
9412Player 7120.2931850.562627
1056Player 8100.7791190.688805
1164Player 980.9046640.766998
1272Player 1060.1293570.544279
1381113Player 11130.1069370.312539
14913Player 12100.6531060.745614
15109Player 13110.5318830.121125
16113Player 14130.1248680.094565
17127Player 1510.6744050.895886
181318Player 1620.0453480.260977
1914513Player 17130.3835670.021962
20Player 18110.2949470.144665
21Player 1980.3162250.779062
22Player 20120.1194250.563879
23Player 2110.9886490.801686
24Player 22110.2333120.151359
25Player 23100.3622240.605264
26Player 2440.769440.533054
27Player 2560.1728920.544648
28Player 26130.3843570.057422
29Player 2720.6976540.175729
30Player 2810.6906850.788707
31Player 2990.5176790.025451
32Player 3090.6299120.053017
33Player 3160.5838810.53648
34Player 3210.5791040.864358
35Player 33120.7798370.560422
36Player 3420.6447050.28677
37Player 3590.1205370.028894
38Player 3620.1146620.305232
39Player 37120.0675910.591905
40Player 38100.8659820.618142
41Player 3960.3456850.540354
42Player 4040.9243340.400991
Original
Cell Formulas
RangeFormula
N3:N42N3=LET(x,L3:L42,y,INDEX(Card,MATCH(x,Assigned_Hole,0)),f,FILTER(y*$J$3,ISNUMBER(y)),tr,ROWS(x),r,ROWS(f),s,f-MMULT((f=TRANSPOSE(f))*(SEQUENCE(r)>=SEQUENCE(,r)),SEQUENCE(r,,,0))+1,IF(x<>"",x,VLOOKUP(INDEX(FILTER(INT(SEQUENCE(tr,,,1/$J$3)),ISNA(MATCH(SEQUENCE(tr),s,0))),XMATCH(P3:P42,SORT(FILTER(P3:P42,x=""),,-1),0)),Hole_Assignment,2)))
O3:O42O3=RANDARRAY(40)
Dynamic array formulas.
Named Ranges
NameRefers ToCells
Assigned_Hole=Original!$J$6:$J$19N3
Card=Original!$I$6:$I$19N3
Hole_Assignment=Original!$I$6:$J$19N3
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
VBA does only copy random values, all the rest is done with formulas.
LET-functions are above my abilities :cry:
paulgunter

paulgunther.xlsm
ABCDEFGHIJKLM
2Non RandomCardPlayerHoleStatic44
3Player 1100,819086973Card Size4Assigned Holenon randomstartaantal
48Player 281holes121 13
5Player 3100,800771881product482 53
6Player 490,7651646193 94
7Player 540,4288811364 134
88Player 6815 174
9Player 740,4016721636 213
10Player 81217 254
11Player 980,72508595582294
12Player 1020,1743797519 314
13Player 1170,72236014310 353
14Player 1270,68833832811 394
15Player 1312112 434
16Player 1420,16617871
17Player 1550,449047086
18Player 1610,002827933
19Player 17121
Blad1
Cell Formulas
RangeFormula
L2L2=SUM(TBL_Holes[aantal])
J4:J15J4=COUNTIF(TBL_Players[Non RandomCard],[@[Assigned Hole]])
K4:K15K4=IF(ROW()-ROW(TBL_Holes[[#Headers],[Assigned Hole]])=1,1,SUM(K3,$G$3,-J3))
L4:L15L4=COUNTIF(TBL_Players[Hole],[@[Assigned Hole]])
G4G4=ROWS(TBL_Holes[Assigned Hole])
G5G5=+G3*G4
C3:C19C3=IF([@[Non RandomCard]]<>"",[@[Non RandomCard]],INDEX(TBL_Holes[Assigned Hole],MATCH(RANK([@Static],MyRandomArray,1),TBL_Holes[start],1)))
 
Upvote 0
Hi Fluff,
I have to keep these as tables since this is just a small part of a larger data base I have working.
I applied the formulas in your example and I'm getting #CALC! errors. I double checked all the cell references and can't seem to find the error.

Random Card.xlsm
ABCDEFGHIJ
1
2Non Random CardPlayerStartGroupRandomStatic
3Player 01#CALC!#CALC!0.9991332020.549061703Card Size4
48Player 028 0.6837519520.701012055
5Player 03#CALC!#CALC!0.7578035870.842910582CardAssigned Hole
6Player 04#CALC!#CALC!0.6098998550.09015092811
78Player 058 0.8311968150.55418455628
8Player 06#CALC!#CALC!0.3838066290.763549902310
9Player 07#CALC!#CALC!0.538944290.842310844412
108Player 088 0.002115630.87338396356
11Player 09#CALC!#CALC!0.9379932350.63879779864
12Player 10#CALC!#CALC!0.2761493330.25913720272
13Player 11#CALC!#CALC!0.6472439740.17285007811
1412Player 1212 0.5384823150.253394704913
15Player 13#CALC!#CALC!0.6068285530.286938851109
16Player 14#CALC!#CALC!0.6523365220.030636228113
1712Player 1512 0.6743546880.857215132127
18Player 16#CALC!#CALC!0.9866462090.1802954361318
19Player 17#CALC!#CALC!0.9042538530.914557395145
20Player 18#CALC!#CALC!0.6925439770.347481513
2112Player 1912 0.1518374380.710534183
2212Player 2012 0.7572292630.190790729
23Player 21#CALC!#CALC!0.0777288380.416866529
24Player 22#CALC!#CALC!0.3002345690.123704669
25Player 23#CALC!#CALC!0.1555134230.508234893
26Player 24#CALC!#CALC!0.9731145410.163258862
27Player 25#CALC!#CALC!0.253271510.310161536
28Player 26#CALC!#CALC!0.4821442030.581927594
29Player 27#CALC!#CALC!0.5124358810.201880639
30Player 28#CALC!#CALC!0.238680120.894778195
31Player 29#CALC!#CALC!0.1102389470.311855049
32Player 30#CALC!#CALC!0.9452803160.179164693
33Player 31#CALC!#CALC!0.5334058920.645835207
34Player 32#CALC!#CALC!0.4594651770.004685599
35Player 33#CALC!#CALC!0.2179750760.151117839
36Player 34#CALC!#CALC!0.5422901750.557757734
37Player 35#CALC!#CALC!0.250098350.225325764
38Player 36#CALC!#CALC!0.9099008340.201272296
39Player 37#CALC!#CALC!0.9055247270.199896846
40Player 38#CALC!#CALC!0.4821066070.956558235
41Player 39#CALC!#CALC!0.5452378760.497686092
42Player 40#CALC!#CALC!0.063162890.562443998
WORKING
Cell Formulas
RangeFormula
C3:C42C3=IF([@[Non Random Card]]<>"",[@[Non Random Card]],VLOOKUP([@Group],Hole_Assignment,2))
D3:D42D3=LET(x,[Non Random Card],y,INDEX(Card,MATCH(x,Assigned_Hole,0)),f,FILTER(y*$J$3,ISNUMBER(y)),tr,ROWS(x),r,ROWS(f),s,f-MMULT((f=TRANSPOSE(f))*(SEQUENCE(r)>=SEQUENCE(,r)),SEQUENCE(r,,,0))+1,IF([@[Non Random Card]]<>"","",INDEX(FILTER(INT(SEQUENCE(tr,,,1/$J$3)),ISNA(MATCH(SEQUENCE(tr),s,0))),XMATCH([@Static],SORT(FILTER([Static],x=""),,-1),0))))
E3:E42E3=RAND()
 
Upvote 0
Have you created the two named ranges Card & Assigned_Hole?
 
Upvote 0
Wow!! I removed the tables and named the ranges instead. Works like a charm!
Thanks so much for all your help!!
There are a lot of unfamiliar formulas in here that I can study and learn. I appreciate that the most.
 
Upvote 0
If I5:J19 is a table, you can just use table references instead.

Glad we could help & thanks for the feedback.
 
Upvote 0
Okay, so there is one ch ink in the armor.
If ALL cells are blank in the "Non_Random_Card" column, an error is generated in the "Group" formula.
 
Upvote 0
Good point, try this slight mod
Excel Formula:
=LET(x,[Non RandomCard],y,INDEX(Card,MATCH(x,Assigned_Hole,0)),f,FILTER(y*$J$3,ISNUMBER(y),""),tr,ROWS(x),r,ROWS(f),s,f-MMULT((f=TRANSPOSE(f))*(SEQUENCE(r)>=SEQUENCE(,r)),SEQUENCE(r,,,0))+1,IF([@[Non RandomCard]]<>"","",INDEX(FILTER(INT(SEQUENCE(tr,,,1/$J$3)),ISNA(MATCH(SEQUENCE(tr),s,0))),XMATCH([@Static],SORT(FILTER([Static],x=""),,-1),0))))
 
Upvote 0
Solution
That sorta fixed it. Now it still calculates even if the Player column is blank. Previously, it would produce an error, which I could hide with conditional formatting. Now it actually assign a number.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,499
Messages
6,125,163
Members
449,210
Latest member
grifaz

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