MSGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Divide into groups.

• Follow

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

```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

"Jeff" wrote:

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

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

Usually you assign a random number to each person and then sort by the
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 _
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 Sub

--
joel
------------------------------------------------------------------------
joel's Profile: 229

[url=&quot;http://www.thecodecage.com&quot;]Microsoft Office Help[/url]

```
 0

2 Replies
681 Views

Similiar Articles:

7/22/2012 6:23:23 AM