+ Reply to Thread
Results 1 to 8 of 8

Generating a list of combinations (similar to Cartesian Product but more than 1 from each)

  1. #1
    Registered User
    Join Date
    10-18-2021
    Location
    Austria
    MS-Off Ver
    365
    Posts
    3

    Post Generating a list of combinations (similar to Cartesian Product but more than 1 from each)

    Long time reader first time asker!

    I have a set of data and I am looking to generate a list of the combinations, I have found VBA and formulas but can't seem to get it right. It is similar to the Cartesian Product but rather than it being one from each list, there are multiples from each list.

    For the example, for the data below I require 2 x West, 4 x North, 1 x South and 5 x East, however if a letter is used in one list it then cannot be used in any of the other lists (e.g. If D is in a combination as West it can't be also in there for North).

    West North South East
    D D A A
    E E B B
    F H C C
    G I F
    J G
    K H
    L I
    J
    K
    L


    It will only ever be 4 columns (lists) or 2 columns (lists). With maximum number of elements in each column set as 10 and the total number to select never more that 5.

    It would be ideal if the data output was each letter appearing in a different cell on a row as a combination. Most of the research and trials the output was generally a delimiter and each combination in one cell.

    I have posted a similar thread (titled the same) on another excel forum but am unable to link it as a new user.

    Any guidance is appreciated!
    Last edited by Excel-can-do-that; 10-18-2021 at 09:01 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,791

    Re: Generating a list of combinations (similar to Cartesian Product but more than 1 from e

    It is not very clear what you want to achieve. Please attach a sample Excel workbook by following the guidelines in the yellow banner at the top of the screen. Your sample workbook should show some examples of what you want as the output.

    Hope this helps.

    Pete

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation Re: Generating a list of combinations (similar to Cartesian Product but more than 1 from e


    Yes exactly the same initial post issue than in its same thread on another forum …

  4. #4
    Registered User
    Join Date
    10-18-2021
    Location
    Austria
    MS-Off Ver
    365
    Posts
    3

    Re: Generating a list of combinations (similar to Cartesian Product but more than 1 from e

    Hi Pete,

    Thanks for your response, I have uploaded an example sheet, hopefully that helps clarify.

    I tried to include the link to the thread I created of the same name on another forum in my initial post but as a new user was unable to. I am yet to receive a helpful response on said thread.

    Thanks again
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,188

    Re: Generating a list of combinations (similar to Cartesian Product but more than 1 from e

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. As you are new here, I will do it for you this time: https://www.mrexcel.com/board/thread...-list.1184747/)
    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
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: Generating a list of combinations (similar to Cartesian Product but more than 1 from e

    158.760 Combinations !!!!
    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

  7. #7
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,418

    Re: Generating a list of combinations (similar to Cartesian Product but more than 1 from e

    a little bit less. 165
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    10-18-2021
    Location
    Austria
    MS-Off Ver
    365
    Posts
    3

    Re: Generating a list of combinations (similar to Cartesian Product but more than 1 from e

    Thank you Bslav! I have been changing the variables around in the workbook and the VBA is working like a charm! You have saved me a lot of time!!
    Last edited by Excel-can-do-that; 10-18-2021 at 09:01 PM. Reason: Further discussion changed requirements

+ 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. Replies: 3
    Last Post: 06-18-2021, 06:04 AM
  2. Generating all possible combinations from my list?
    By acmarston in forum Excel General
    Replies: 1
    Last Post: 10-25-2020, 06:05 AM
  3. Copy, sort, remove doubles, Cartesian product
    By kleanthis1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2017, 04:02 AM
  4. Replies: 4
    Last Post: 04-19-2016, 06:54 PM
  5. Generating a list of combinations
    By tomhardy1491 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2015, 11:29 PM
  6. [SOLVED] Generating full list of scenarios (or combinations) of data in columns
    By cparker347 in forum Excel General
    Replies: 6
    Last Post: 07-28-2015, 10:28 AM
  7. [SOLVED] Generating a List of Possible Permutation Combinations
    By glennchung in forum Excel General
    Replies: 3
    Last Post: 05-12-2014, 06:39 PM

Tags for this Thread

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