+ Reply to Thread
Results 1 to 8 of 8

Please help to.modify the code to Possible 7/1-49 Lottery Number Combinations

  1. #1
    Registered User
    Join Date
    07-11-2011
    Location
    Hong Kong
    MS-Off Ver
    Excel 2003
    Posts
    22

    Please help to.modify the code to Possible 7/1-49 Lottery Number Combinations

    Dear all expert

    Does anyone can know how to generate all lotto 7/49 combinations ? i saw many website, still cannot find the vba code, the most closest one is

    Please Login or Register  to view this content.
    Does any expert can vary this to All Possible 7/1-49 Lottery Number Combinations. The total is 13983816 combination. Thank you very much.

    Thanks in advance,
    Isaac
    Last edited by Isaacliu; 12-07-2016 at 01:17 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Please help to.modify the code to Possible 7/1-49 Lottery Number Combinations

    There are more efficient techniques than this, but your sample code is easily fixed by merely changing the numbers at the end of FOR statements.
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 12-07-2016 at 11:49 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-11-2011
    Location
    Hong Kong
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Please help to.modify the code to Possible 7/1-49 Lottery Number Combinations

    Can you teach me the efficient techniques to generate all lotto 7/49 combinations

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Please help to.modify the code to Possible 7/1-49 Lottery Number Combinations

    Ok, here is how I would list all the possible selection of 7 numbers from 1-49. Your post #1 indicates you expect 13million results, and that is far too low. I ran this macro and stopped it at 49million and growing. So, even with this technique, it will take a while.

    Your original macro was actually writing out each combination to the worksheet one at a time. That will take forever. This method builds a list of 65000 results in memory, then writes them all out at once. Then repeats. So even with 100s of millions of results it will be 65000 times faster.

    Also, your original macro limited to 65k rows I presume to maintain Excel 2003 compatibility, but your macro would run out of columns pretty fast. This new version will keep adding sheets as needed until it is done.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-11-2011
    Location
    Hong Kong
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Please help to.modify the code to Possible 7/1-49 Lottery Number Combinations

    Dear JBeaucaire,

    Thank you very much., but after run, why started at
    24 25 33 36 38 40 46

    and looks without 1 2 3 4 5 6 7
    or i misunderstand something.

    Thank you very much.
    Isaac

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Please help to.modify the code to Possible 7/1-49 Lottery Number Combinations

    It didn't start there. You are just looking at the LAST sheet created when it was finished. Go back to the first sheet in the workbook to see the first numbers. They are all there.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  7. #7
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Please help to.modify the code to Possible 7/1-49 Lottery Number Combinations

    just out of curiosity would it be difficult to change code for 3 from 42 numbers

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Please help to.modify the code to Possible 7/1-49 Lottery Number Combinations

    Same edit as before. The LAST inner FOR loop hold the highest number. Each loop working up from there reduces by 1. Then the lowest number is listed in the first FOR loop.
    Please Login or Register  to view this content.

+ 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. [SOLVED] Lottery: Combinations of 6 numbers in a range of number 1 - 60
    By Baroem in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 01-02-2020, 04:49 PM
  2. [SOLVED] Geting highest number value from list with values which are text/number combinations
    By igormigor in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-25-2016, 10:48 AM
  3. Permutations/Combinations with Lottery
    By ablan008 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-18-2016, 12:07 AM
  4. Replies: 3
    Last Post: 09-15-2015, 03:00 AM
  5. Assign random number for a lottery
    By Alibuchan in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-11-2013, 10:35 PM
  6. [SOLVED] Pick 3 Lottery Number Macro
    By ssjagger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-28-2013, 11:20 AM
  7. Lottery Number Checking
    By madnesstiger in forum Excel General
    Replies: 5
    Last Post: 02-15-2007, 07:57 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