Generate list of players for four school teams

imcl75

New Member
Joined
Mar 26, 2024
Messages
10
Office Version
  1. 365
Platform
  1. MacOS
Hi. I want to be able to create 4 football teams from a list of names which is updated weekly. The list starts as a list of all names (these are the names of all children in 3 year groups in my school) and to begin with I will enter an "x" next to their name if they want to play in the games that week. Then, I want to take all the children who have an x next to their name and randomly split them into 4 teams of (as close as possible) equal numbers. It would be useful to be able to have a few specific players from the Year 6 list (which I will identify) put into different teams rather than the same team so the best players get spread out . I've attached the sheet which I am starting with.... any help hugely appreciated as this will save me a lot of effort each week and stop me having to have loads of bits of paper with kids names on which I manually have to put into teams.

1712159007263.png


1712159043925.png
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi @imcl75 I am happy to take a look at this for you in the hope that I can provide a helpful solution.
Given the essential need for a random split, will involve using an Excel 'random' function. Random functions are 'volatile' and as such their values change every time a spreadsheet is triggered to recalculate. There are ways to 'freeze' a set of randomly generated values. If you are running vba code,a Macro, to fulfil your task then it is no great problem to code to 'freeze' any randomly generated value. Otherwise, if you are reliant upon cell formulas, then there will likely be a need for the user to 'freeze' the randomly generated values at some point by a quick copy paste or similar.
Unless you tell me otherwise, I will assume that you may not wish or even be allowed to use vba?

A couple of other questions spring to mind.
Will numbers always be such that you will split total x's int 4 teams, irrespective of the number of x's per team?
Stupid extreme would be 12 x's = 3 per team

After you have placed the 'key' year sixers across the teams is it just a random free for all with the balance of the players?
Or is it better to attempt to spread each year separately over each of the 4 teams?

The more I type, the more I wonder whether using vba might not be an easier solution.
In ant event I will not be able to attempt do anything positive until tomorrow.
 
Upvote 0
Hi @imcl75 I am happy to take a look at this for you in the hope that I can provide a helpful solution.
Given the essential need for a random split, will involve using an Excel 'random' function. Random functions are 'volatile' and as such their values change every time a spreadsheet is triggered to recalculate. There are ways to 'freeze' a set of randomly generated values. If you are running vba code,a Macro, to fulfil your task then it is no great problem to code to 'freeze' any randomly generated value. Otherwise, if you are reliant upon cell formulas, then there will likely be a need for the user to 'freeze' the randomly generated values at some point by a quick copy paste or similar.
Unless you tell me otherwise, I will assume that you may not wish or even be allowed to use vba?

A couple of other questions spring to mind.
Will numbers always be such that you will split total x's int 4 teams, irrespective of the number of x's per team?
Stupid extreme would be 12 x's = 3 per team

After you have placed the 'key' year sixers across the teams is it just a random free for all with the balance of the players?
Or is it better to attempt to spread each year separately over each of the 4 teams?

The more I type, the more I wonder whether using vba might not be an easier solution.
In ant event I will not be able to attempt do anything positive until tomorrow.
Thanks for the fast reply! Am happy to use macros / vba but very novice there (can record macros, assign to short cuts, buttons etc but don't know vba coding)

Once the lists (teams) are generated I will print them so if they changed after that it wouldn't be a problem. Triggering via a macro would be ideal.

There will always be 4 teams as we always get plenty of players interested. Totally random is fine after the key year 6 players have been split up. Whatever, and whenever you can take a look is great. Thanks again
 
Upvote 0
Do you have a sensible likely maximum for number of names in the year lists?
Also a sensible max for players per team?
 
Upvote 0
Do you have a sensible likely maximum for number of names in the year lists?
Also a sensible max for players per team?
There are about 60 children in each year group but lots of them never play. Maximum number would realistically be 100 and even that is in excess of real world number. 20 or so per team is a maximum - 20-a-side makes for a terrible game of football!
 
Upvote 0
@imcl75 Ok, here it is.
Essentially, I chose to utilise standard Excel 365 functionality. To be honest, I didn't see the volatility of Rand() being too much of of an annoyance for the user. However, I have just included a small macro that effectively avoids the volatility. It would be a very simple matter to switch it back to not requiring via at all if you wish.

As it stands, you will need a button in the 'Teams' sheet and assign to it the macro 'RandTeams'
There are 'helper' columns in columns L:P of the Players sheet. You can choose to hide these if you wish.
In the 'Players' sheet:
In general, you will edit the year lists to have an 'x' assigned to the name of intended players.
However, in year 6 only, you will need to assign 'k' rather than 'x' to denote any 'key' players who you wish to ensure be randomly split across the four teams.

In the 'Teams' sheet:
To refresh the randomisation of the teams - Click the button to run the 'RandTeams' macro.

Picking Teams.xlsm
ABCDEFGHIJKLMNOP
1Year 4Year 5Year 6Player PoolRefRandomRandom Names
2CHy4-1xCHy5-1CHy6-1CHy6-2k1.63204148CHy6-4
3CHy4-2CHy5-2xCHy6-2kCHy6-4k1.88278006CHy6-16
4CHy4-3CHy5-3CHy6-3xCHy6-10k1.04794096CHy6-2
5CHy4-4xCHy5-4CHy6-4kCHy6-16k1.65176345CHy6-25
6CHy4-5xCHy5-5xCHy6-5xCHy6-25k1.38310405CHy6-10
7CHy4-6xCHy5-6CHy6-6CHy4-1x0.05419298CHy4-11
8CHy4-7CHy5-7xCHy6-7xCHy4-4x0.04868209CHy4-13
9CHy4-8CHy5-8CHy6-8xCHy4-5x0.77568949CHy6-17
10CHy4-9CHy5-9CHy6-9CHy4-6x0.21191974CHy5-5
11CHy4-10CHy5-10xCHy6-10kCHy4-11x0.99049223CHy6-13
12CHy4-11xCHy5-11xCHy6-11CHy4-12x0.09497617CHy6-5
13CHy4-12xCHy5-12xCHy6-12xCHy4-13x0.94356146CHy4-5
14CHy4-13xCHy5-13xCHy6-13xCHy4-18x0.07302424CHy4-24
15CHy4-14CHy5-14CHy6-14xCHy4-21x0.30359707CHy5-10
16CHy4-15CHy5-15CHy6-15xCHy4-24x0.76983619CHy6-21
17CHy4-16CHy5-16xCHy6-16kCHy4-27x0.56492531CHy5-16
18CHy4-17CHy5-17CHy6-17xCHy5-2x0.56241888CHy5-11
19CHy4-18xCHy5-18CHy6-18CHy5-5x0.82310079CHy5-22
20CHy4-19CHy5-19xCHy6-19xCHy5-7x0.33253302CHy5-19
21CHy4-20CHy5-20CHy6-20CHy5-10x0.76485303CHy5-25
22CHy4-21xCHy5-21CHy6-21xCHy5-11x0.65203706CHy6-7
23CHy4-22CHy5-22xCHy6-22CHy5-12x0.27236244CHy4-27
24CHy4-23CHy5-23CHy6-23xCHy5-13x0.28334031CHy5-2
25CHy4-24xCHy5-24CHy6-24CHy5-16x0.74977019CHy6-15
26CHy4-25CHy5-25xCHy6-25kCHy5-19x0.59206734CHy6-12
27CHy4-26CHy5-26CHy6-26CHy5-22x0.59593102CHy6-3
28CHy4-27xCHy5-27CHy6-27CHy5-25x0.58617269CHy6-23
29CHy4-28CHy5-28CHy6-28CHy6-3x0.38010436CHy6-14
30CHy4-29CHy5-29CHy6-29CHy6-5x0.78985268CHy5-7
31CHy4-30CHy5-30CHy6-30CHy6-7x0.57727037CHy4-21
32CHy6-8x0.02654532CHy5-13
33CHy6-12x0.43208187CHy5-12
34CHy6-13x0.8117463CHy4-6
35CHy6-14x0.34333776CHy4-12
36CHy6-15x0.44813105CHy4-18
37CHy6-17x0.89539295CHy4-1
38CHy6-19x0.00074591CHy4-4
39CHy6-21x0.76169693CHy6-8
40CHy6-23x0.37824756CHy6-19
41
42
43
Players
Cell Formulas
RangeFormula
L2:M40L2=LET(plyrs,SORT((VSTACK(A2:B101,D2:E101,G2:H101)),2,1),FILTER(plyrs,INDEX(plyrs,,2)<>0))
P2:P40P2=LET(rnd,SORTBY(L2:L101,N2:N101,-1),FILTER(rnd,rnd<>0,))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G2:H101Expression=$H2="x"textNO
D2:E60Expression=$E2="x"textNO
A2:B60Expression=$B2="x"textNO
G2:H101Expression=$H2="k"textYES



Picking Teams.xlsm
ABCD
1Team ATeam BTeam CTeam D
2CHy6-4CHy6-16CHy6-2CHy6-25
3CHy6-10CHy4-11CHy4-13CHy6-17
4CHy5-5CHy6-13CHy6-5CHy4-5
5CHy4-24CHy5-10CHy6-21CHy5-16
6CHy5-11CHy5-22CHy5-19CHy5-25
7CHy6-7CHy4-27CHy5-2CHy6-15
8CHy6-12CHy6-3CHy6-23CHy6-14
9CHy5-7CHy4-21CHy5-13CHy5-12
10CHy4-6CHy4-12CHy4-18CHy4-1
11CHy4-4CHy6-8CHy6-19
12
13
14
15
16
17
18
19
20
21
22
23
24
Teams
Cell Formulas
RangeFormula
A2:D21A2=LET(tmem,INDEX(Players!P2:P101,SEQUENCE(20,4,1,1),),IF(tmem=0,"",tmem))
Dynamic array formulas.


VBA:
VBA Code:
Sub RandTeams()
    With Sheets("Players").Range("N2:N101")
       .Formula = "=SORT(IF(L2="""","""",IF(M2=""x"",RAND(),RAND()+1)),,-1)"
        .Value = .Value
    End With
    Sheets("Teams").Select
End Sub

Edit: I see that I have an incorrect end of range row for a couple of the CF formulas. Should be 101 not 60. !!

Hope that helps?
 
Upvote 1
@imcl75 Ok, here it is.
Essentially, I chose to utilise standard Excel 365 functionality. To be honest, I didn't see the volatility of Rand() being too much of of an annoyance for the user. However, I have just included a small macro that effectively avoids the volatility. It would be a very simple matter to switch it back to not requiring via at all if you wish.

As it stands, you will need a button in the 'Teams' sheet and assign to it the macro 'RandTeams'
There are 'helper' columns in columns L:P of the Players sheet. You can choose to hide these if you wish.
In the 'Players' sheet:
In general, you will edit the year lists to have an 'x' assigned to the name of intended players.
However, in year 6 only, you will need to assign 'k' rather than 'x' to denote any 'key' players who you wish to ensure be randomly split across the four teams.

In the 'Teams' sheet:
To refresh the randomisation of the teams - Click the button to run the 'RandTeams' macro.

Picking Teams.xlsm
ABCDEFGHIJKLMNOP
1Year 4Year 5Year 6Player PoolRefRandomRandom Names
2CHy4-1xCHy5-1CHy6-1CHy6-2k1.63204148CHy6-4
3CHy4-2CHy5-2xCHy6-2kCHy6-4k1.88278006CHy6-16
4CHy4-3CHy5-3CHy6-3xCHy6-10k1.04794096CHy6-2
5CHy4-4xCHy5-4CHy6-4kCHy6-16k1.65176345CHy6-25
6CHy4-5xCHy5-5xCHy6-5xCHy6-25k1.38310405CHy6-10
7CHy4-6xCHy5-6CHy6-6CHy4-1x0.05419298CHy4-11
8CHy4-7CHy5-7xCHy6-7xCHy4-4x0.04868209CHy4-13
9CHy4-8CHy5-8CHy6-8xCHy4-5x0.77568949CHy6-17
10CHy4-9CHy5-9CHy6-9CHy4-6x0.21191974CHy5-5
11CHy4-10CHy5-10xCHy6-10kCHy4-11x0.99049223CHy6-13
12CHy4-11xCHy5-11xCHy6-11CHy4-12x0.09497617CHy6-5
13CHy4-12xCHy5-12xCHy6-12xCHy4-13x0.94356146CHy4-5
14CHy4-13xCHy5-13xCHy6-13xCHy4-18x0.07302424CHy4-24
15CHy4-14CHy5-14CHy6-14xCHy4-21x0.30359707CHy5-10
16CHy4-15CHy5-15CHy6-15xCHy4-24x0.76983619CHy6-21
17CHy4-16CHy5-16xCHy6-16kCHy4-27x0.56492531CHy5-16
18CHy4-17CHy5-17CHy6-17xCHy5-2x0.56241888CHy5-11
19CHy4-18xCHy5-18CHy6-18CHy5-5x0.82310079CHy5-22
20CHy4-19CHy5-19xCHy6-19xCHy5-7x0.33253302CHy5-19
21CHy4-20CHy5-20CHy6-20CHy5-10x0.76485303CHy5-25
22CHy4-21xCHy5-21CHy6-21xCHy5-11x0.65203706CHy6-7
23CHy4-22CHy5-22xCHy6-22CHy5-12x0.27236244CHy4-27
24CHy4-23CHy5-23CHy6-23xCHy5-13x0.28334031CHy5-2
25CHy4-24xCHy5-24CHy6-24CHy5-16x0.74977019CHy6-15
26CHy4-25CHy5-25xCHy6-25kCHy5-19x0.59206734CHy6-12
27CHy4-26CHy5-26CHy6-26CHy5-22x0.59593102CHy6-3
28CHy4-27xCHy5-27CHy6-27CHy5-25x0.58617269CHy6-23
29CHy4-28CHy5-28CHy6-28CHy6-3x0.38010436CHy6-14
30CHy4-29CHy5-29CHy6-29CHy6-5x0.78985268CHy5-7
31CHy4-30CHy5-30CHy6-30CHy6-7x0.57727037CHy4-21
32CHy6-8x0.02654532CHy5-13
33CHy6-12x0.43208187CHy5-12
34CHy6-13x0.8117463CHy4-6
35CHy6-14x0.34333776CHy4-12
36CHy6-15x0.44813105CHy4-18
37CHy6-17x0.89539295CHy4-1
38CHy6-19x0.00074591CHy4-4
39CHy6-21x0.76169693CHy6-8
40CHy6-23x0.37824756CHy6-19
41
42
43
Players
Cell Formulas
RangeFormula
L2:M40L2=LET(plyrs,SORT((VSTACK(A2:B101,D2:E101,G2:H101)),2,1),FILTER(plyrs,INDEX(plyrs,,2)<>0))
P2:P40P2=LET(rnd,SORTBY(L2:L101,N2:N101,-1),FILTER(rnd,rnd<>0,))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G2:H101Expression=$H2="x"textNO
D2:E60Expression=$E2="x"textNO
A2:B60Expression=$B2="x"textNO
G2:H101Expression=$H2="k"textYES



Picking Teams.xlsm
ABCD
1Team ATeam BTeam CTeam D
2CHy6-4CHy6-16CHy6-2CHy6-25
3CHy6-10CHy4-11CHy4-13CHy6-17
4CHy5-5CHy6-13CHy6-5CHy4-5
5CHy4-24CHy5-10CHy6-21CHy5-16
6CHy5-11CHy5-22CHy5-19CHy5-25
7CHy6-7CHy4-27CHy5-2CHy6-15
8CHy6-12CHy6-3CHy6-23CHy6-14
9CHy5-7CHy4-21CHy5-13CHy5-12
10CHy4-6CHy4-12CHy4-18CHy4-1
11CHy4-4CHy6-8CHy6-19
12
13
14
15
16
17
18
19
20
21
22
23
24
Teams
Cell Formulas
RangeFormula
A2:D21A2=LET(tmem,INDEX(Players!P2:P101,SEQUENCE(20,4,1,1),),IF(tmem=0,"",tmem))
Dynamic array formulas.


VBA:
VBA Code:
Sub RandTeams()
    With Sheets("Players").Range("N2:N101")
       .Formula = "=SORT(IF(L2="""","""",IF(M2=""x"",RAND(),RAND()+1)),,-1)"
        .Value = .Value
    End With
    Sheets("Teams").Select
End Sub

Edit: I see that I have an incorrect end of range row for a couple of the CF formulas. Should be 101 not 60. !!

Hope that helps?
This works perfectly - thank you so much. I hope it wasn't a lot of work!
 
Upvote 0
This works perfectly - thank you so much. I hope it wasn't a lot of work!
Great stuff - you are most welcome. Just be thankful you're not having to pay me by the hour! ;)
 
Upvote 0
Would a more equal allocation between the years be fairer?
I suppose yes, i.e. spreading out the children from the three different year groups across the 4 teams so one team doesn't end up with loads of the Y6 children - who are older and stronger if not actually better players. Is that an easy change?
 
Upvote 0

Forum statistics

Threads
1,215,394
Messages
6,124,683
Members
449,180
Latest member
kfhw720

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