• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Creating balanced teams: men/women + another factor

dourpil

Member
Hi all!

I have a list of 71 names that I need to dispatch in 12 teams.

In the attached file:

Table1 is the list of names (I've replaced them with numbers). Column "H/F" is "Man/Woman". Column "team" (name is poorly chosen) is the service they work in. We're trying to have as few persons from the same service in the same team. Column 'num' is a sequential number I used for convenience' sake.


I created a macro that does the following:
Take items one by one in the table starting from top to bottom. For each item, pick a random number between 1-12 (the future team in which the person will be assigned). If the team is full, pick another random number.

The teams are filled in the range I4:T9

In the range I12:T17, I use index/match to check if male or female
In I18:T18, I count the number of women
In G5, I check if the number of women is between 2 and 3 (I have ~30 females and ~40 males in total)

In the range I28:T43, I check how many people from the same service are in the same team.
In G6, I check if there's no more than 2 people from the same service in the same team.


The macro, when finished filling the teams, checks if the two conditions in G5 and G6 are met. If not, it starts over.


G7 is kind of a 'score' marker: I check how many teams have 2 people from the same service. Low score = better. But I don't use it in formulas or in the code.


Is there a more elegant way to do that?
I tried reducing the max number of people from the same service to 1, but haven't let the macro run long enough to find a solution that works. How could I do that with more reliability?


Thanks !


[Note: due to not paying enough attention when I added "application.calculation = xlcalculationmanual", you need two button presses to make the code work as intended]
 

Attachments

  • team generation.XLSM
    31.8 KB · Views: 42
Last edited:
Hi ,

I have manually done this , since it did not take too much time ; probably writing code / formulae to do this might take longer.

See if the results are correct.

Narayan
 

Attachments

  • team generation.XLSM
    33.1 KB · Views: 59
Hi NARAYANK and thanks for your reply. Indeed, your team distribution is acceptable but has 11 instances of two individuals from the same service in the same team. This is similar to what the macro I wrote is able to provide when it runs for a few seconds.
 
Hi ,

Can you point out one such instance ? It is possible I have not understood your requirement correctly.

Name the team and the service.

Narayan
 
Hi again,

In your example: Team n°3 has two persons (num 40 and 41) from Service #9.

This is relatively acceptable but I was wondering if there would be a way to have the minimum amount of those instances. After running my macro several times, I think the least amount I got was 8.
 
Hi ,

I do not understand.

When I look at the table (which is all that I have populated) , the Service is in column D , and the Team is in column G.

According to what I see , 40 is in Team 4 , while 41 is in Team 5.

Narayan
 
Oh right ! It's my bad, I didn't pay enough attention and thought the columns you had added were helper columns or something like that.

Your distribution works perfectly, thanks a lot and sorry about the confusion!
 
Hi ,

I have manually done this , since it did not take too much time ; probably writing code / formulae to do this might take longer.

See if the results are correct.

Narayan

Did you distribute the Team column on your own? I'm not sure I am following every step of this spreadsheet. I would also like to achieve something similar but with a different number of teams!
 
I ( kenduck ) would also like to achieve something similar but with a different number of teams!
... then kenduck should open a new thread with own file to get answers
This thread belong to OP.
 
Back
Top