traineeross <traineer...@discussions.microsoft.com> wrote...
....
>I have used the randbetween function to create a number between
>1-6, and then used the choose function to use th erandom number to
>pick a name from the list of staff in the choose function.
....
>Is there a way in which i can control the number of times a
>persons name appears per week and per fortnight. (ie not more than
>once a week, and must have at least one shift per fortnight)
....
So there are only 6 people, and there are 7 days in a week, and only
one shift per week and at least one shift every two weeks. So there
are fewer than 6 shifts per week but at least 6 shifts every two weeks
to which to assign staff?
If there were 5 shifts per week, simply including the first shift of
the second week in the single shift logic for the first week would
ensure the employee who didn't have a shift in the first week would
have the first shift of the second week. Then start the logic over.
Put the employee names in a contiguous, single-column range named
Staff. Then if the first shift assignment would be in, say, cell D3,
and the second shift assignment in cell D4, etc., try these formulas.
D3:
=INDEX(Staff,INT(1+6*RAND()))
D4 [array formula]:
=INDEX(Staff,SMALL(IF(COUNTIF(D$3

3,Staff)=0,
ROW(Staff)-MIN(ROW(Staff))+1),INT(1+(6-COUNTA(D$3

3))*RAND())))
Fill D4 down into D5

8. Select D4

8, run Edit > Replace, and replace
$ with nothing to remove the absolute references. Then copy D3

8 and
paste it into D9

14. Then copy D4 and paste it into D9 to ensure that
the employee with the 6th shift doesn't get the 7th shift too. Then
copy D9

14 and repeatedly paste into further cells below D14.