+ Reply to Thread
Results 1 to 8 of 8

How to generate a random number list from 1 to 10 with no dupes or volatile functions

  1. #1
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    266

    How to generate a random number list from 1 to 10 with no dupes or volatile functions

    Hi forum!

    Just wondering how to generate a random order list between 1 and 10, with no dupes or functions that will result in the order being randomized again anytime the spreadsheet is loaded/changed.

    I have attached an example of what I want to achieve below.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: How to generate a random number list from 1 to 10 with no dupes or volatile functions

    Here's how I would usually do something like this:

    1) Generate 10 unique random numbers in 10 convenient cells (say A1:A10, for example). =RAND()
    2) Rank the numbers to get the integers 1 to 10 in random order B1 =RANK(A1,$A$1:$A$10) copied/pasted/filled into B2:B10.
    3) Select B1:B10 -> copy -> Select C1 -> Paste special as values.

    A1:B10 will update with each calculate event, constantly generating random lists. Whenever I need a new randomization, I can copy/paste as values from column B into column C.

    Will something like that work for you?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    266

    Re: How to generate a random number list from 1 to 10 with no dupes or volatile functions

    Can this be done without a helper column, negating the need for the needless 0.xxxxx random numbers generated between 0 and 1?

    And can this also be done without volatile functions like rand() which change on every sheet calculation?

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: How to generate a random number list from 1 to 10 with no dupes or volatile functions

    I'm usually optimistic that anything is possible with enough time, effort, and ingenuity. If you help us understand all of your requirements, I'm confident we can help you come up with something.

    For something like this, the easiest approach that I see to getting rid of the volatile spreadsheet columns is to move the random number generation to another programming language and use the spreadsheet as the output container (so the spreadsheet is not actually generating the random numbers). Traditionally, Excel users have defaulted to VBA for this sort of thing. Recently, I have seen some rumblings that Microsoft is trying to push Office users towards Javascript as an alternate programming language. Basically, you choose the programming language you want to use, program it to perform the same steps (generate 10 random unique numbers and rank them), then send the output to the spreadsheet. Are you allowed to use "macros" written in another programming language for this, or are you required to use native Excel functions?

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: How to generate a random number list from 1 to 10 with no dupes or volatile functions

    Please try at C2

    =AGGREGATE(15,6,ROW(C$1:C$10)/ISNA(MATCH(ROW(C$1:C$10),C$1:C1,)),RANDBETWEEN(1,ROWS(C$1:C$10)-ROWS(C$2:C2)+1))

    RAND and RANDBETWEEN are volatile functions.
    But the random can be stop by set calcuation opiton to manual and Press F9 to Random

    Or Enable Iteretive calculation and use circular reference.
    E2
    =IF($A$1=1,E2,AGGREGATE(15,6,ROW(E$1:E$10)/ISNA(MATCH(ROW(E$1:E$10),E$1:E1,)),RANDBETWEEN(1,ROWS(E$1:E$10)-ROWS(E$2:E2)+1)))

    Stop random by key 1 in A1, delete 1 in A1 to random again

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

    Re: How to generate a random number list from 1 to 10 with no dupes or volatile functions

    Small macro fires on Workbook_Open event.
    Each time the workbook is opened a random set of numbers will appear in column A.
    No on-sheet formula or helper columns.
    torachan
    Attached Files Attached Files

  7. #7
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    266

    Re: How to generate a random number list from 1 to 10 with no dupes or volatile functions

    Hi all thanks for your solutions. I will try them out now!

  8. #8
    Forum Contributor JulianS96's Avatar
    Join Date
    11-01-2019
    Location
    England
    MS-Off Ver
    365 (work-99%), 2016 (home-1%)
    Posts
    266

    Re: How to generate a random number list from 1 to 10 with no dupes or volatile functions

    Quote Originally Posted by torachan View Post
    Small macro fires on Workbook_Open event.
    Each time the workbook is opened a random set of numbers will appear in column A.
    No on-sheet formula or helper columns.
    torachan
    I'm getting
    "Run-time error '1004':
    Method 'Range' of object '_Global' failed"

+ 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: 11-26-2017, 08:58 AM
  2. Generate random number from a list range with condition
    By okido in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-03-2017, 01:34 AM
  3. Replies: 5
    Last Post: 06-21-2013, 10:40 AM
  4. [SOLVED] Generate random 6-16-byte random hexadecimal number
    By jsamuelshn in forum Excel General
    Replies: 6
    Last Post: 07-20-2012, 10:38 AM
  5. Replies: 0
    Last Post: 06-25-2012, 07:21 AM
  6. generate a random number and use if function to generate new data
    By Dogdoc1142 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-25-2006, 10:50 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