View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
bigjim bigjim is offline
external usenet poster
 
Posts: 67
Default Selecting from a randomized list

I understand. I'll see if I can make it clearer. I have a list of names in
col B. B1 through B50. In Col A, before each name, there is a box. If the
user, puts an X in the box, that name will be used in the team selection.
When all the names have been selected, then I want to randomly place the name
into different teams, such as team A, Team B, etc. the teams may or may not
be of equal size depending on how many are selected. The ideal number for
each team will be 3, with the next ideal being 4, and the next being 5 per
team. I want to use VBA code so that once the names are selected, the user
will select the "form teams" button, and the code will randomize the selected
names and assign them to teams. The excel worksheet will list the selected
players in col L : If(a1="","",b1). Col M has rand() in each cell. I have
code that will sort col L and Col M together using Col M Ascending. the
result will be random but will contain some names and some blanks. The
problem I'm having is once this sort takes place, how do I assign them to
teams. I hope this explains things better and I sure do appreciate the help
I get from you guys.

Jim

"Joe User" wrote:

"bigjim" wrote:
There will not always be five per team or even
six teams as this will vary, but if I can it to work
for this case I can make it work with the others.


Not necessarily. If you are not clear about your input and output
requirements, you are likely to get a solution that works for the special
case that you mentioned, but it is difficult to generalize.


"Mike H" wrote:
Select the 2 columns and sort on column B and
the names will be randomley grouped.

[....]
I've got that done, but my problem is the new list
that is sorted has names and blanks interspersed
throughout the list.


I don't understand why. You said: "I have a list of 50 people out of which
I have selected 30 names". The reasonable inference is that the 30 names are
in 30 contiguous cells. I am sure that is what MikeH assumed. Is that not
the case?

If it is not the case, can you make it so easily?

If so, then MikeH's solution is probably the simplest to explain, if that
works for you. I would only add that in column C, I would enter the names of
each team repeated in contiguous cells as many times as the number of team
members for each team. You can add that after sorting. If you do it before
sorting, be sure to select only columns A and B (the names and the random
numbers) for the sort.

However, you are posting to the "Excel Programming" forum. That is usually
used for VBA questions (macros and UDFs), although the distinctions among
forums have blurred over the years. Are you looking for an Excel solution or
VBA solution, or don't you care?

Moreover, MikeH's approach can be tedious if you want a process that you can
repeat often or for many sets of 30 people. Are you looking for a less
labor-intensive approach?


----- original message -----

"bigjim" wrote:
I've got that done, but my problem is the new list that is sorted has names
and blanks interspersed throughout the list. I need to know how to select
the first five for team 1, the 2nd for team 2, etc. There will not always
be five per team or even six teams as this will vary, but if I can it to work
for this case I can make it work with the others. Sorry I wasn't clear on my
question.

Jim

"Mike H" wrote:

Hi,

Let's assume your names are in Col A starting in A1. Put this formula in b1

=RAND()

copy down to the length of Col a
Select the 2 columns and sort on column B and the names will be randomley
grouped.
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"bigjim" wrote:

I would like to randomly assign people to different teams, from a list of
names. For example: I have a list of 50 people out of which I have selected
30 names. I want to randomly assign these 30 people to 6 teams of 5 each.