+ Reply to Thread
Results 1 to 6 of 6

Formula for random numbers with given numbers

  1. #1
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    84

    Formula for random numbers with given numbers

    Hi,

    I wonder if i can pick random numbers from specific numbers.

    Say, I would like to pick 3 of any numbers from following numbers (1, 3, 19, 29, 100, 210, 1000).

    Please advise if there is any way to do this.

    Thanks
    MK
    Last edited by dogbural; 01-24-2022 at 06:58 AM. Reason: solved

  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,780

    Re: Formula for random numbers with given numbers

    Where would these numbers appear? In separate cells or all in one cell?
    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
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,822

    Re: Formula for random numbers with given numbers

    Do you want to allow repeats? Something like =INDEX($A$1:$A$7,RANDBETWEEN(1,7)) will randomly choose one number from the list entered in A1:A7. 3 copies of that function will randomly choose three numbers, with the possibility of repeats.

    Do you want the selections to be unique? I like to think of that as a "shuffle/sort" operation that usually looks something like entering the numbers into A1:A7, entering random unique numbers in B1:B7 (RAND() function), sorting the list by column B, then reading from the top of column A.

    What kind of random selection are you trying to accomplish here?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,025

    Re: Formula for random numbers with given numbers

    One way to produce unique values (non-repeating):

    =INDEX(A:A,AGGREGATE(15,6,ROW($A$1:$A$7)/NOT(COUNTIF($C$1:C1, INDEX(A:A,ROW($A$1:$A$7)))), RANDBETWEEN(1,8-ROW(C1))))

    The bit in red is the number of values in your choice... plus 1.

    You seem to be using an older version of Excel than me. So, please refer to the attached file. If the formulae are enclosed within a pair of { }, these are array formulae.

    These are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see the curly brackets { } appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Registered User
    Join Date
    08-30-2009
    Location
    melbourne
    MS-Off Ver
    Excel 2016 / 2019
    Posts
    84

    Re: Formula for random numbers with given numbers

    Thanks All.

  6. #6
    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,780

    Re: Formula for random numbers with given numbers

    If you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

+ 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. Filtering random numbers without regenerating random numbers
    By ptack in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-07-2022, 04:03 PM
  2. generate n random numbers not duplicated for each id numbers with Vba
    By fatoom91 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-21-2019, 03:31 PM
  3. Replies: 5
    Last Post: 09-08-2018, 07:20 PM
  4. [SOLVED] Rearranging random numbers in a column into ordered numbers in another row
    By joel.mugabe in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-09-2016, 05:02 AM
  5. [SOLVED] Macro to pull 6 random numbers from a list of numbers.
    By Shellybelly in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2014, 07:07 AM
  6. Random numbers to generate amount between two numbers
    By maverickbv80 in forum Excel General
    Replies: 2
    Last Post: 09-08-2010, 11:21 AM
  7. Replies: 1
    Last Post: 06-07-2006, 02:25 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