+ Reply to Thread
Results 1 to 6 of 6

Make All Possible Permutations

  1. #1
    Registered User
    Join Date
    06-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    9

    Make All Possible Permutations

    You guys were so helpful with my first question, I have another one:

    I have two arrays with two columns each

    The first array is Part Number and Part Name
    The second array is Color Code and Color Name

    What I'm looking to do is make one array with all the possible combinations of the two arrays. I know how to do this manually with concatenation, but it is a long list of both Parts and Colors.

    See the attached spreadsheet with my starting point and end goal (highlighted).

    Demo Spreadsheet 2.xlsx

    Thanks,

    Jared

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Make All Possible Permutations

    Hi,

    This should replicate your desired output:

    Please Login or Register  to view this content.
    abousetta
    Last edited by abousetta; 06-30-2013 at 04:02 AM.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Make All Possible Permutations

    @ abousetta,

    Very nice!

    Just a small "Typo" here:

    Please Login or Register  to view this content.
    Should be "Part Name"
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Make All Possible Permutations

    Hi Winon,

    Yes, you're right... I updated the code above.

    Honestly the code could have been more efficient by converting the ranges to arrays, looping through the arrays creating a third array using the Scripting dictionary and printing the keys on the sheet, but it's too late at night for me to be coding arrays right now . Plus unless the list is massive, the OP won't feel the difference in execution time.

    abousetta

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Make All Possible Permutations

    I used a helper sheet to get the individual elements of the desired results into separate columns then concatenated the columns back on sheet1.
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  6. #6
    Forum Contributor
    Join Date
    08-22-2012
    Location
    nj, us
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: Make All Possible Permutations

    to check, use this formula:


    nPk=n!/(n-k)!

    n= total amount and k= number of cells you need to choose. there should be (n!/(n-k)!) ways

+ 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