+ Reply to Thread
Results 1 to 11 of 11

How to select random Number from a list and populate another sheet

  1. #1
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    How to select random Number from a list and populate another sheet

    Hi all,

    Thought I'd ask if something was possible in a general sense first before getting in to specific details.

    I will have a list of numbers in Column A on Sheet 1 along the lines if 1251. 1252, 1555, 4596 (All four digits) one 4 digit number per line. These are fixed numbers and the only ones that can be used.

    On Sheet 2 I will have Columns

    Column A called Date
    Column B called H1
    Column C called H2

    So now comes the hard question:

    What I need to have is something to populate Sheet 2 cell B2 with a number randomly taken from Sheet 1 then repeat for cell C2.
    Then repeat this for cell B3, C4, etc down to say line 200.

    How on earth do I do this ?

    Hope this makes sense.

    I have not got a spreadsheet put together yet that I can show.

    Thanks in advance,
    Last edited by Lensmeister; 05-12-2022 at 07:09 AM. Reason: Excellent solution
    A mad football researcher and Statistician - ok just mad really !

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: How to select random Number from a list and populate another sheet

    You could apply a random number to each row on Sheet1 using =RAND(), sort the data via that number to randomise them then just take the first half and put it in column B on Sheet2 and the second half and put it on column C on Sheet2.

    If you're open to using VBA you can have the whole thing happen in the blink of an eye at the click of a button.

    BSB

  3. #3
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: How to select random Number from a list and populate another sheet

    Thanks.
    The 4 digit numbers represent actual cat numbers in a database.
    so aren't actually just random numbers there is only one instance of each number.

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: How to select random Number from a list and populate another sheet

    Here's one very straightforward and easy to follow method using VBA.
    Please Login or Register  to view this content.
    Click the button on Sheet1 in the attached to see it in action.

    BSB
    Attached Files Attached Files

  5. #5
    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. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,659

    Re: How to select random Number from a list and populate another sheet

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
    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.

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: How to select random Number from a list and populate another sheet

    Quote Originally Posted by Lensmeister View Post
    Thanks.
    The 4 digit numbers represent actual cat numbers in a database.
    so aren't actually just random numbers there is only one instance of each number.
    I merely meant adding a random number alongside the numbers you have in order to be able to sort based on those which would randomise the order of the cat numbers.

    BSB

  7. #7
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: How to select random Number from a list and populate another sheet

    Quote Originally Posted by BadlySpelledBuoy View Post
    Here's one very straightforward and easy to follow method using VBA.
    Please Login or Register  to view this content.
    Click the button on Sheet1 in the attached to see it in action.

    BSB
    That is Blooming AMAZING ... thanks Exactly how I'd imagined the results to look like.
    I'll read through the VBA Reputations added to say thanks

  8. #8
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: How to select random Number from a list and populate another sheet

    Quote Originally Posted by AliGW View Post
    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.

    Thanks
    Normally I would have had a sample set of data and done that buy as I mentioned I hadn't got a spreadsheet together as yet as I want to know if it could be done.

    BSB has hit the nail on the head perfectly.

  9. #9
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: How to select random Number from a list and populate another sheet

    Glad I could help.

    I can be improved upon with things like putting the data back in the original order, if necessary, or made dynamic to cater for varying list lengths etc. But should be a step in the right direction for ya

    BSB

  10. #10
    Forum Contributor
    Join Date
    12-05-2006
    Location
    London
    MS-Off Ver
    Excel 365 (Version 2008) [work] & 365 [home]
    Posts
    182

    Re: How to select random Number from a list and populate another sheet

    It is.

    I will get a full list of the Cat Numbers ot of the DB we have then able to paste them in to Sheet 1 Column A

    Those are the numbers that'll need to the randomising in to Sheet 2.

  11. #11
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: How to select random Number from a list and populate another sheet

    Depending on the database software you use you could have Excel reach in and get the numbers for you. But that means the code gets a little more indepth and technical.

    Good luck with it. Give me a shout if you need it amending in any way.

    BSB

+ 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. VBA to select either number or % of random rows
    By Hollyball in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-19-2021, 03:27 PM
  2. Replies: 11
    Last Post: 11-19-2019, 11:36 PM
  3. [SOLVED] Random select an asset number from a list based on one condition
    By letitbe0430 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-22-2019, 03:44 AM
  4. Random populate sheet with predefined information
    By Stingone in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-15-2014, 09:34 AM
  5. Select Random Number from List
    By dreicer_Jarr in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-23-2009, 04:01 PM
  6. How do I find random number in list of random alpha? (Position is.
    By jlahealth-partners in forum Excel General
    Replies: 0
    Last Post: 02-08-2005, 02:06 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