+ Reply to Thread
Results 1 to 13 of 13

Lotto question: list of every combination of 6 number with no sequence repeated

  1. #1
    Registered User
    Join Date
    12-15-2018
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    5

    Lotto question: list of every combination of 6 number with no sequence repeated

    Morning nad hi to all, this is my first post so sorry if I have missed anything.

    So I have been searching around these forums and many others but cannot find the solution to my problem, I have found mainly VBA etc solutions but was wondering if it can be done souly in excel, so my problem.

    1 column of 20 rows say 1-20
    I would like a list of every combination of 6 number with no sequence repeated i.e. 1,2,3,4,5,6 is same as 6,5,4,3,2,1.

    Now I know this is going to be a huge list but here is the twist. I only want the combinations that add up to between 110 and 140. If the formula could be inclusive of this criteria then the list that is outputted wouldn't be so huge, but how or even can it be done. This output would also be useful depending on size if it was spread across the sheet i.e. column A is the 1-20 column B,C blank then results in the next 6 cells/columns then 2 blank column next 6 cells/column etc.

    I am sorry if this has been discussed and would like a pointer to that post as I have not found anything with this twist.

    Please ask if anymore info is required.

    Cheers
    Last edited by AliGW; 12-16-2018 at 03:34 AM.

  2. #2
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Apologies but it's another Lotto question

    1) You say you want every combination of 6 numbers but you don't say how many numbers you are choosing from.

    2) Are you saying it's not acceptable to generate the list in a single column? A single column would probably be the easiest to implement.

  3. #3
    Registered User
    Join Date
    12-15-2018
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    5

    Re: Apologies but it's another Lotto question

    Ok sorry thought it was clear.

    The range is column A 1-20 ( which would be numbers of my choosing) but using 1-20 as a reference.
    I said about the multiple columns incase 1 set of 6 cells/columns would not be enough.

  4. #4
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Apologies but it's another Lotto question

    You may not be interested in this as it is VBA based and doesn't exactly follow your layout guidelines, but it does address the basic problem of counting the number of combinations whose sum falls in a specified range.

    Choosing 6 from 20 with order not mattering results in 38760 combinations. For testing I chose numbers in the range 2:40. Fully 47% of the combinations met the criterion that the sum falls in the range 110..140

    Here is a summary of the workbook I have uploaded:

    The ChosenNumbers worksheet lets you specify your 20 numbers in column-A.It also provides a summary count of how many combinations meet the "sum" criterion.

    The MacroGenerated worksheet is created, as the name implies, by running the TestCNR macro. It generates all 38760 combinations using numbers 1..20. Once generated it does not need to be changed. Credit Allen Wyatt at excelribbon.tips for the macro. I have used it entirely unchanged.

    The NumbersAndSum worksheet uses the MacroGenerated worksheet values as indices into the User chosen numbers in the ChosenNumbers worksheet to create a 38760 row set of combinations this time using your chosen numbers. I then added a "sum" column. The "Count" cell D8 on the ChosenNumbers worksheet uses this sum to display the count of combinations that meet the "sum" criterion. To see the individula combinations that meet the "sum" criterioon you can simply filter on the Sum column to show only those that fall in the range 110 to 140.

    I AM UNABLE TO UPLOAD THE WORKBOOK, ZIPPED IT IS 2.# MB WHICH IS WELL WITHIN ADVERTIZED LIMITS. If there is any interest in this based on my description then I will try to find a way.

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

    Re: Apologies but it's another Lotto question

    I started this thread with the beginnings of something like this without VBA https://www.excelforum.com/tips-and-...thout-vba.html At present, it generates all possible permutations. I have not taken the time to adapt it to combinations or to combinations with other rejection criteria. It should give the beginnings of something. At worst, you have it generate every permutation, then use a filter with some helper columns to reject those permutations that represent duplicate combinations and meet the rejection criteria.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

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

    Re: Lotto question: list of every combination of 6 number with no sequence repeated

    Your thread title is not adequate. I have changed it for you this time - please review our forum rules and take more care with your thread titles in future, Thanks.
    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.

  7. #7
    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
    43,997

    Re: Lotto question: list of every combination of 6 number with no sequence repeated

    I think you have no non-VBA possibilities...
    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

  8. #8
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Lotto question: list of every combination of 6 number with no sequence repeated

    Here is the workbook associated with post #4. I was unable to find a way around the posting size limit so what I have done instead is have the workbook dynamically resize itself based on how many combinations are to be generated. It is posted so that it is choosing 6 numbers from 8 resulting in just 28 combinations. Change ChosenNumbers!D3 from 8 to 20 and click the "Compute Combinations" button to have the workbook resize itself to your requirement. I won't bother posting the VBA as it is tangential to the requirements of this thread.

    Macros of course need to be enabled.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    12-15-2018
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    5
    Sorry to take so long to get back, work and life this time of year is hecktic. Awesome replies and ty so much for this I'll give it a try asap. This is fantastic. Thanks all who replied.

  10. #10
    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,635

    Re: Lotto question: list of every combination of 6 number with no sequence repeated

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

  11. #11
    Registered User
    Join Date
    12-15-2018
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    5

    Re: Lotto question: list of every combination of 6 number with no sequence repeated

    Quote Originally Posted by AliGW View Post
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Yep as soon as I can verify it working and nothing else is needed.

  12. #12
    Registered User
    Join Date
    12-15-2018
    Location
    New Zealand
    MS-Off Ver
    2016
    Posts
    5

    Re: Lotto question: list of every combination of 6 number with no sequence repeated

    This is absolutely amazing, currently it is amck on the mark of what I needed.
    Thanks again.

  13. #13
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Lotto question: list of every combination of 6 number with no sequence repeated

    Glad to help and thanks for the reputation point!

+ 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] Apologies
    By Doc.AElstein in forum The Water Cooler
    Replies: 20
    Last Post: 05-31-2016, 11:33 AM
  2. [SOLVED] Apologies, off-topic question re Outlook 2013 forum ?
    By twaccess in forum Excel General
    Replies: 5
    Last Post: 06-13-2014, 10:07 AM
  3. lotto man
    By lotto man in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-09-2012, 06:49 AM
  4. Lotto Question --- Excel Help
    By Emilyng in forum Excel General
    Replies: 2
    Last Post: 03-01-2012, 09:45 AM
  5. Comparing Named ranges apologies for the dodgey post below
    By Sam Crump in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-07-2006, 08:55 AM
  6. Checking for blank rows in database - with apologies to Norman Jon
    By Peter Rooney in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2005, 12:05 PM
  7. apologies for posting it again but...
    By J_J in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-19-2005, 05:07 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