Asking for better logic to avoid multiple if's.

S

Spy128Bit

I have been trying to find a better method to loop through the data
than a series of if statements. What I am trying to do is go down a
list of employees and determine which preference they were able to fit
into and subtract that from a set value..

If we started with 1 in each time frame from 6:00AM to 2:00PM in two
hour increments the following data would end up as listed below.

Name Full/Part Rank 1 2 3 4 5
Student A Full 1 8:00 AM 10:00 AM 6:00 AM 12:00 PM 2:00 PM
Student B Full 2 6:00 AM 8:00 AM 10:00 AM 12:00 PM 2:00 PM
Student C Full 4 6:00 AM 8:00 AM 10:00 AM 12:00 PM 2:00 PM
Student D Full 5 6:00 AM 8:00 AM 10:00 AM 12:00 PM 2:00 PM
Student E Full 6 12:00 PM 10:00 AM 8:00 AM 6:00 AM 2:00 PM

Assigned
Student A 8:00 AM - First preference and a slot available so it's
filled.
Student B 6:00 AM - First preference and a slot available so it's
filled.
Student C 10:00 AM - First two preference are already completed
filled so 3rd is used.
Student D 12:00 PM - First three preferences are already filled so
4th is used.
Student E 2:00 PM - First four preferences are already filled so
5th is used.

On the full list there are a varying number of slots available in each
time slot. What I was beginning to do so far was loop across checking
each slot for availability then moving on to the next one if there was
none or subtracting one and going to the next employee. I could
continue this way but it would end up being close to 25-30 if
statements and I'm just asking if there is better logic to use here
than that. Any ideas would be appreciated.

Excel 2003 is the version being used.

Thanks!
 
D

Don Guillett

A macro something like looking down each name with an offset as to their 1st
choice, offset 2 for 2nd,etc>check count of list of preference>if empty
copy/move name to bottom of that list and exit the for .>if not look in the
next list> etc
 

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