Divide into groups.

J

Jeff

I have a list of 25 to 50 people and would like to divide them into 13
groups. How would I do this?
 
J

Jeff

Just to clarify. The names or in A1 – A52 and I would like to sort them in A1
– 52. If there are only 26 names then they would be in groups of 2 down A1 –
A52. Thanks! Jeff
 
J

joel

I assume you are looking to randomly assign the people to the groups.
Is there any other restictions? Do you want to evenly divide thes
people among the groups so 25 people would have 12 groups of 2 peopl
and one group of 1. Or some other division.


Usually you assign a random number to each person and then sort by th
random number. Then perform an algorith to make the groups

Sub RandomGroups()

Dim Groups(0 To 12, 0 To 3)

'initialize random generator
Randomize

'Assume name are on column A
LastRow = Range("A" & Rows.Count).End(xlUp).Row

'assign rtandom number
For RowCount = 1 To LastRow
Range("B" & RowCount) = Rnd
Next RowCount

'sort on random number
Rows("1:" & LastRow).Sort _
header:=xlNo, _
key1:=Range("B1"), _
order1:=xlAscending

For RowCount = 1 To LastRow
GroupNum = (RowCount - 1) Mod 13
IndexNum = Int((RowCount - 1) / 13)
Groups(GroupNum, IndexNum) = Range("A" & RowCount)
Next RowCount


End Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top