+ Reply to Thread
Results 1 to 4 of 4

Use random value from a range, but excluding values from specific cells

  1. #1
    Registered User
    Join Date
    10-16-2017
    Location
    Bristol, England
    MS-Off Ver
    Microsoft 365
    Posts
    10

    Use random value from a range, but excluding values from specific cells

    Hi guys,

    I'm trying to do something which I suspect is very simple, but I have Friday brain and can't figure it out. I have attached a very simplified version of a rota that I'm creating, which shows two officers on duty each day, but every Friday needs an additional officer for emergency cover. I want the emergency cover to be randomly generated from the list of officers, but to never be the same as the officers already on duty that day. So, in my example attached, how do I ensure that F4 is not the same as F2 or F3?

    Thanks in advance
    Attached Files Attached Files
    Last edited by Sarah Baker; 06-25-2021 at 07:03 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Use random value from a range, but excluding values from specific cells

    Try this:

    =INDEX(Table2[Names], LARGE(MATCH(ROW(Table2[Names]), ROW(Table2[Names]))*NOT(COUNTIF($F$2:F3, Table2[Names])), RANDBETWEEN(1, ROWS(Table2[Names])-ROW(A1)+1)))

    If you don't have Excel 365, you may need to enter this as an array formula.

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Last edited by AliGW; 06-25-2021 at 07:05 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    10-16-2017
    Location
    Bristol, England
    MS-Off Ver
    Microsoft 365
    Posts
    10

    Re: Use random value from a range, but excluding values from specific cells

    Thanks very much... that seems to be working perfectly on my example sheet. The problem I now have is trying to work my way through it so I can understand it well enough to apply it to my much more complicated real scenario - perhaps I'll attempt that after a lunch break!!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Use random value from a range, but excluding values from specific cells

    Ah! Bad move ... Over-simplifying your sample data is never a good idea!

+ 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. Find Bottom 10 values from range of cells in a Row excluding zeros
    By analystbank in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-28-2020, 11:33 PM
  2. Replies: 1
    Last Post: 09-12-2018, 06:16 AM
  3. Replies: 1
    Last Post: 02-20-2018, 06:56 AM
  4. [SOLVED] Looking for final four values in range, excluding any blank cells
    By OffTheFairway22 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-02-2015, 07:32 AM
  5. Assigning x number of random cells in a range a specific value
    By DGtil in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-21-2014, 06:52 AM
  6. Random time generation (excluding range)
    By Scopedope in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 04:07 PM
  7. [SOLVED] Macro to generate a random number between 2 specific values into specific cells.
    By Nerfmagnet in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-10-2013, 11:45 AM

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