+ Reply to Thread
Results 1 to 8 of 8

How to generate all possible five number kombinations of group of numbers without macro

  1. #1
    Registered User
    Join Date
    09-09-2011
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    91

    How to generate all possible five number kombinations of group of numbers without macro

    Hi

    I have numbers from 1 to maximum 20 and instead of some number there might be letter X somewhere. I want to generate all possible five kombinations (not permutations) of them without macro. How can i do that? Please look the attachment to find out more.
    Please notice that in the attachment there is numbers from one to 20 and two X letters in the middle. But the formula should also work if i next time but there numbers from 1 to 14 and no X letters. The biggest number what there can be is 20.
    Thanks for the help already.
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to generate all possible five number kombinations of group of numbers without macr

    You said you want combinations, not permutations, but your example shows permutations. Combinations would look like this:

    1 1 1 1 1
    1 1 1 1 2
    1 1 1 1 3
    1 1 1 1 X
    1 1 1 1 5
    1 1 1 1 6
    1 1 1 1 7
    1 1 1 1 8
    1 1 1 1 9
    1 1 1 1 10
    and so on.

    Please clarify what you are looking for.

    This is a difficult problem to write a general solution for without macros. The way I would do this is to write a macro that generates all the formulas for you. That would be specific to your problem of selecting 5 items from a set of 20. I wouldn't mind doing that if you can clarify your problem.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-09-2011
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: How to generate all possible five number kombinations of group of numbers without macr

    Thanks for your response.
    Ok, maybe i did not say it right. What i want is that any of the numbers can't be twice in the five number serie. For example there can't be 1 2 3 4 1. Also there can't be two five number series where is exactly the same numbers but in different order. For example there can't be 1 2 4 5 6 and 1 4 2 5 6. Did this clear my problem?

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to generate all possible five number kombinations of group of numbers without macr

    I apologize, the mistake is mine. The table I gave shows combinations with repetition (sometimes called with replacement). You want combinations without repetition.

    Let me take a look and see what I can come up with. Meantime, others are of course welcome to provide their own solutions.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to generate all possible five number kombinations of group of numbers without macr

    I apologize, the mistake is mine. The table I gave shows combinations with repetition (sometimes called with replacement). You want combinations without repetition.

    Let me take a look and see what I can come up with. Meantime, others are of course welcome to provide their own solutions.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to generate all possible five number kombinations of group of numbers without macr

    There's a workbook at https://app.box.com/shared/nqljsd3nlu that will do this. For example, here are the first 16 combinations of 20 choose 5:

    Row\Col
    B
    C
    D
    E
    F
    G
    H
    I
    J
    2
    n
    20
    3
    m
    5
    4
    C(n,m)
    15,504
    5
    6
    Comb
    n
    C1
    C2
    C3
    C4
    C5
    Helper
    7
    1
    20
    4
    3
    2
    1
    0
    1
    8
    2
    20
    5
    3
    2
    1
    0
    2
    9
    3
    20
    5
    4
    2
    1
    0
    3
    10
    4
    20
    5
    4
    3
    1
    0
    4
    11
    5
    20
    5
    4
    3
    2
    0
    5
    12
    6
    20
    5
    4
    3
    2
    1
    1
    13
    7
    20
    6
    3
    2
    1
    0
    2
    14
    8
    20
    6
    4
    2
    1
    0
    3
    15
    9
    20
    6
    4
    3
    1
    0
    4
    16
    10
    20
    6
    4
    3
    2
    0
    5
    17
    11
    20
    6
    4
    3
    2
    1
    2
    18
    12
    20
    6
    5
    2
    1
    0
    3
    19
    13
    20
    6
    5
    3
    1
    0
    4
    20
    14
    20
    6
    5
    3
    2
    0
    5
    21
    15
    20
    6
    5
    3
    2
    1
    3
    22
    16
    20
    6
    5
    4
    1
    0
    4


    The elements are always numbered 0 to N-1 (i.e., 0 to 19 for 20 items).
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to generate all possible five number kombinations of group of numbers without macr

    Here is a version of shg's reference that is tailored to your specific problem.

    Note that combinations get big fast--there are over 15,000 combinations of 5 from 20.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    09-09-2011
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    91

    Re: How to generate all possible five number kombinations of group of numbers without macr

    Thank you both for the help. My problem is now solved.

+ 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. Extracting Number from Dates to generate a string of numbers...
    By Adam_S in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-23-2014, 04:48 AM
  2. [SOLVED] I have the average number i need but want to generate random numbers
    By Michaelsalmon in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-20-2014, 05:40 PM
  3. Replies: 8
    Last Post: 11-18-2013, 04:24 PM
  4. Replies: 6
    Last Post: 08-04-2005, 10:05 PM
  5. Replies: 4
    Last Post: 03-31-2005, 11: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