+ Reply to Thread
Results 1 to 3 of 3

Random number generator and matching all numbers

  1. #1
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Smile Random number generator and matching all numbers

    Hi Guys,

    I made a post entitled "Autosort numbers from low to high" and in this post I wanted to generate a range of random numbers and sort them from low to high. Dav uploaded a VBA routine to do this and can be seen in the link below.

    http://www.excelforum.com/showpost.p...7&postcount=15

    I wanted to expand on this code and do a probability experiment.

    Now in cells D14 to M14 I will manually enter a selection of non duplicated numbers, in Cell F18 I wanted a counter which will increment each time the rumbers are randomised.

    Now when I hit the 'generate random number' button this will set the counter in cell F18 to 0 and then the code will start generating random numbers.

    Now the numbers need to random generate until all of the numbers in cells A2 to A11 match the values in D14 to M14 and then the loop can stop once all 10 random generated numbers match the numbers I enter in row 14, now the counter should tell how many loops it took to generate the match all 10 numbers.

    Can someone please help me expand on the code in the attached spreadsheet in the link above to achieve this?

    Thanks.
    Last edited by Zyphon; 03-12-2008 at 05:21 AM.
    Best Regards.

    Michael
    -----------------------------------
    Windows Vista, Microsoft Office 2007

  2. #2
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Smile

    Any ideas guys?

  3. #3
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Smile

    I have an idea how to achieve this. I used a COUNTIF command in cells D16 to M16, so basically if say M14 equals any of the numbers in cells A2 to A11 then it is 1 otherwise it is 0. Cell O16 sums these numbers up so that we could have up to a maximum of 10.

    All I need is a code that will set the counter to 0 in cell F18, I have the code already that generates the random numbers. What I need is once the numbers have been generated. Then the counter number should be incremented by 1 and aybe a Do While loop until the value in cell F18=10.

    This should then tell me how many attempts it would take to match all 10.

    Can anyone help please?

+ 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