+ Reply to Thread
Results 1 to 9 of 9

Random Shifts allocation

  1. #1
    Registered User
    Join Date
    03-24-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Lightbulb Random Shifts allocation

    Good afternoon everyone,

    I am trying to have my Excel spreadsheet to generate random shifts pattern based on the following:

    Column A (A2 to A17): Names of team members
    Cell B1 to F1: Day of the week (Monday to Friday)

    I have 2 shifts available in cell A19 (Early Shift) and A20 (Late Shift).

    There are also 2 restrictions is:

    - If a member does a late shift on a day, he cannot do an early shift the next day.
    - Only 1 person on Early and 1 person on Late per day.

    I have attached the spreadsheet.

    Could anyone help on this please?

    Thank you very much
    Attached Files Attached Files
    Last edited by fburaud; 07-21-2015 at 12:07 PM. Reason: typo in title

  2. #2
    Valued Forum Contributor
    Join Date
    03-22-2013
    Location
    Australia,NSW, Wirrimbi
    MS-Off Ver
    Excel 2013
    Posts
    1,057

    Re: Random Shits allocation

    lol.. you might want to edit your Thread title..

  3. #3
    Registered User
    Join Date
    03-24-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Random Shifts allocation

    Thank you apo

  4. #4
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: Random Shifts allocation

    Hi,
    Please use this Procedure, this should work.

    Please Login or Register  to view this content.
    Let me know if you have any questions, but i rarely go online though !

    Cheers
    Lex

    Add rep if you like my answer

  5. #5
    Registered User
    Join Date
    03-24-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Random Shifts allocation

    Hi lex,

    Thank you for your reply.

    It looks good. However, I forgot to add one restriction: only 1 person can be on Early and 1 person on Late per day.

    Are you able to amend your code?

    Thank you
    Fab
    Last edited by fburaud; 07-21-2015 at 08:15 AM.

  6. #6
    Registered User
    Join Date
    03-24-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Random Shifts allocation

    In lex' absence, could someone please assist with my request?

    Thank you

  7. #7
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: Random Shifts allocation

    Hi,

    how about the other team member? for example, on Monday, i have allocated Early shift to team member 1 and late shift to team member 5. what would happen to the remaining team? leave it blank [no work?]?

    Cheers
    Lex

  8. #8
    Registered User
    Join Date
    03-24-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Random Shifts allocation

    Hi Lex,

    That's right, no specific shift (flexi) so the cell must be blank.

    Also, shifts must be allocated to cell that are blank, if a cell isn't blank, then no shift can be allocated.

    I think I've got it:

    Sub ScheduleRNG()
    Dim i As Integer
    Dim EarlyRNG As Integer
    Dim LateRNG As Integer
    Dim Proceed As Boolean
    Proceed = False


    For i = 2 To 6
    Do Until Proceed = True
    EarlyRNG = Int((17 - 2 + 1) * Rnd + 2)
    LateRNG = Int((17 - 2 + 1) * Rnd + 2)

    Do Until EarlyRNG <> LateRNG
    LateRNG = Int((17 - 2 + 1) * Rnd + 2)
    Loop

    If Cells(EarlyRNG, i).Value = "" And Cells(LateRNG, i).Value = "" _
    And Cells(EarlyRNG, i - 1).Value <> "Late 10:30 - 19:00" Then
    Cells(EarlyRNG, i).Value = "Early 07:00 - 15:30"
    Cells(LateRNG, i).Value = "Late 10:30 - 19:00"
    Proceed = True
    End If
    Loop
    Proceed = False
    Next i


    End Sub

    Do you have a better way?

    Thank you
    Fab

  9. #9
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: Random Shifts allocation

    Hi Fab,

    that looks good, i would do the same too!

    Cheers
    Lex

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 09-30-2012, 03:03 PM
  2. [SOLVED] Ordering random letters for a chance-random based TV gameshow.
    By Askalian in forum Excel General
    Replies: 4
    Last Post: 06-19-2012, 02:26 PM
  3. Random allocation of amount
    By expert40 in forum Excel General
    Replies: 0
    Last Post: 02-12-2012, 08:44 AM
  4. Allocation using VBA
    By naveenhs5 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 11-21-2011, 07:25 AM
  5. Non-random numbers generated by excel's data analysis random gener
    By Allie in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-17-2005, 02:05 AM
  6. Replies: 2
    Last Post: 09-13-2005, 12:05 PM
  7. F-key allocation
    By HELLBOY787 in forum Excel General
    Replies: 1
    Last Post: 06-30-2005, 07:05 AM
  8. How do I find random number in list of random alpha? (Position is.
    By jlahealth-partners in forum Excel General
    Replies: 0
    Last Post: 02-08-2005, 02:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1