+ Reply to Thread
Results 1 to 5 of 5

Random sets without repeats to completion

  1. #1
    Registered User
    Join Date
    05-03-2019
    Location
    USA
    MS-Off Ver
    OFFICE 2013
    Posts
    7

    Random sets without repeats to completion

    Hello all.

    I am looking to create a matrix of RNG numbers 8 rows and 8 columns from 1 through 8 without any repeats in any column or row. It would be great if the function "calculate now" in excel would regenerate different randomization of this matrix. Any ideas? I have tried Rand() then rank function but that is only one column or row to get it to happen in 8 rows and columns without repeating has had me at a loss.

    Thank you so very much.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Random sets without repeats to completion

    Here's one approach, using VBA iterations of random numbers in a listobject table.

    Please Login or Register  to view this content.
    It will try up to 1000 times per cell to find a valid random value which doesn't already exist in the intersecting row / column; then reset the table and attempt again, if a valid value is not found..

    This code also logs the result, number of attempts, and time taken.

    I repeated 50 times - every time I got a successful matrix result. It took an average of 36.1 attempts, taking an average of 3.9 seconds to generate a successful 8x8 matrix.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    05-03-2019
    Location
    USA
    MS-Off Ver
    OFFICE 2013
    Posts
    7

    Re: Random sets without repeats to completion

    I am so sorry for sounding dense. I do not use VBE and I am not familiar with it. Do I just copy and Paste this code in a module in VBE and run it? I tried that and I get the message "Run-time error '9': Subscript out of range" The script line in the code that is highlighted is "Set lo = Sheet1.ListObjects(1)"

    Thank you for your help in this.

    M.

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Random sets without repeats to completion

    Apologies - I intended to attach a workbook to demonstrate. Attached to this post.

    This code relies on having a Table, with 8 columns, and 8 rows, on worksheet Sheet1.

    The logging function also needs a Table with 3 columns on worksheet shLog - you can easily remove and ignore this bit, it was just for performance testing.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-03-2019
    Location
    USA
    MS-Off Ver
    OFFICE 2013
    Posts
    7

    Re: Random sets without repeats to completion

    Thank you so very much Olly. It works perfectly. I cannot thank you enough.

    M.

+ 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] Random sets without repeats to completion
    By radm1f in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-05-2019, 12:44 PM
  2. [SOLVED] Random Select From 3,000,000 numbers Without Repeats
    By ssjagger in forum Excel General
    Replies: 8
    Last Post: 11-14-2018, 07:09 PM
  3. Random Groups w/No Repeats
    By BrandiL in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-21-2018, 05:38 PM
  4. Random Lists with no Repeats
    By cliff2017 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 01-29-2017, 02:03 PM
  5. [SOLVED] Random Number with No Repeats
    By Hannah122392 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-11-2016, 01:56 PM
  6. VBA random numbers NO repeats
    By jamiegfinch in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 12-18-2015, 12:01 AM
  7. Excel 2007 : Random number generator without repeats
    By HRJames in forum Excel General
    Replies: 4
    Last Post: 03-24-2011, 11:37 AM

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