+ Reply to Thread
Results 1 to 4 of 4

Unique Random Number generator

  1. #1
    Registered User
    Join Date
    06-13-2007
    MS-Off Ver
    Office 365 (Version 2306)
    Posts
    72

    Unique Random Number generator

    Hi,

    Is there a (non-VBA) way to generate a given number of unique random numbers from a list of unique numbers?

    Eg. Column A has an unspecified number of unique positive integers in it.

    I want to be able to enter an integer in B1 (that is obviously less than the number of elements in column A) and have that many unique random elements from Column A listed in column C.

    So for example, A1:A10 might have the numbers 1 .. 10.

    The user enters the number 3 (say) in B1 and then 3 unique random numbers from column A are listed from C1:C3.

    Thanks in advance.
    Regards,

    David Obeid

    http://david.obeid.googlepages.com

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Hello David,

    Here's a way using a "helper" column.

    Assume column A has integers from A1 down with no gaps
    B1 has the number of numbers to generate. In the first row of another column, e.g. J1 put this formula

    =RAND()

    and copy down as far as you might have numbers in column A (doesn't matter if you go further)

    Now in C1 use this formula copied down as many rows as the maximum value you might have in B1

    =IF(ROWS(C$1:C1)>B$1,"",INDEX(A:A,RANK(J1,OFFSET( J$1,,,COUNT(A:A)))))

    This should now give you your list of random numbers from column A

    Any sheet re-calculation will re-generate the numbers (also press F9)

    You might want to hide column J

  3. #3
    Forum Contributor
    Join Date
    09-25-2004
    Posts
    269
    Input formula in cell C2 and copy down.

    Please Login or Register  to view this content.

    The formula is an-array need to hold down:


    Ctrl,Shift,Enter

  4. #4
    Registered User
    Join Date
    06-13-2007
    MS-Off Ver
    Office 365 (Version 2306)
    Posts
    72
    Thankyou all!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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