+ Reply to Thread
Results 1 to 8 of 8

Generate Random Number for "Work from Home"

  1. #1
    Forum Contributor
    Join Date
    03-12-2012
    Location
    Singapore
    MS-Off Ver
    MS 365
    Posts
    532

    Generate Random Number for "Work from Home"

    Hi, not sure if this is even possible in Excel.

    I have 7 staff under me and i have to plan which staff come back to office everyday. Denote by x in my attachment
    Our policy is that Everyday must have at least 3 staff (can be more but cannot be less)
    Each staff to be back to office at least 2 times per week. (best is 2 but if no choice, can be 3)

    However, we have to change our schedule every week. Its quite troublesome for me to always plan as i always has to make sure the above is met.

    Hence i am thinking if Excel is possible to generate random array base on the above requirement.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,331

    Re: Generate Random Number for "Work from Home"

    Formulas with a macro works pretty well - open the file, enable macros, and click the button.

    Note that with 7 staff members and 15 slots to fill, Steve will always have 3 days in the office (since he is the only one selected to be in more than twice)
    Attached Files Attached Files
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    03-12-2012
    Location
    Singapore
    MS-Off Ver
    MS 365
    Posts
    532

    Re: Generate Random Number for "Work from Home"

    Quote Originally Posted by Bernie Deitrick View Post
    Formulas with a macro works pretty well - open the file, enable macros, and click the button.

    Note that with 7 staff members and 15 slots to fill, Steve will always have 3 days in the office (since he is the only one selected to be in more than twice)

    Haha. Thanks! Its fun watching the x jumping here n there.

  4. #4
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Generate Random Number for "Work from Home"

    Here is a solution with a recursive formula.

    The recursive formula generates an absolutely random schedule that meets all your requirements.
    The person who is assigned 3 times is also random.

    Please add to the namemanager: genplan:
    Please Login or Register  to view this content.
    and delete all expected results and try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by HansDouwe; 09-13-2023 at 03:31 PM. Reason: One bracket removed. See Post #5.

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,331

    Re: Generate Random Number for "Work from Home"

    Wow! - I got an error message about this part:

    --MID(c,SEQUENCE(,7)) ,1)

    I think it needs one fewer right parens:

    --MID(c,SEQUENCE(,7) ,1)

    then it worked wonderfully....

  6. #6
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Generate Random Number for "Work from Home"

    @Bernie, Thanks for the feedback and pointing the error. It is a typo. I'll remove the bracket in Post #4.

    In the attached file the formula is correct.
    Last edited by HansDouwe; 09-13-2023 at 03:45 PM.

  7. #7
    Forum Contributor
    Join Date
    03-12-2012
    Location
    Singapore
    MS-Off Ver
    MS 365
    Posts
    532

    Re: Generate Random Number for "Work from Home"

    hey, thanks for the help. It work well. Sorry that i am not able to response in time as i am overseas.

  8. #8
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Generate Random Number for "Work from Home"

    You are Welcome!

    Thanks for the feedback and glad to have helped. .

    If you haven't already, please consider adding reputation to all helpers you think they deserve.
    In that case please click * Add Reputation left below their answers.

+ 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. [SOLVED] Generate Random Char "x" in Range with Condition
    By ionelz in forum Excel General
    Replies: 26
    Last Post: 11-01-2022, 06:44 AM
  2. Replies: 3
    Last Post: 11-19-2020, 08:30 PM
  3. Replies: 1
    Last Post: 02-24-2018, 10:56 AM
  4. When I Press Home in keyboard, sheet called "Home" should activate
    By janagan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2015, 03:53 AM
  5. Team Rotating "Work From Home" Day
    By cjlevinsk22 in forum Excel General
    Replies: 2
    Last Post: 04-28-2015, 05:12 PM
  6. Replies: 3
    Last Post: 01-02-2014, 02:15 PM
  7. Trying to generate the letter "X" in random blocks
    By awaters76 in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 07-08-2009, 03:29 PM

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