+ Reply to Thread
Results 1 to 5 of 5

Permutation & Combinations of Names of different lengths

  1. #1
    Registered User
    Join Date
    12-04-2012
    Location
    india
    MS-Off Ver
    2021
    Posts
    45

    Permutation & Combinations of Names of different lengths

    Hi,

    i want to know if there is a macro which will give me the permutations and combinations of 5 names of different length that i have .

    Example: Below are the 5 names of different lengths . for example

    Names
    Mark
    Michelle
    Sandra
    Steve
    Aaron

    Output should be as below.

    Output
    MMSSA
    MMSSr
    MMSSo
    MMSSN
    MMSTA
    MMSTR
    MMSTO
    MMSTN
    MMSEA
    MMSER
    MMSEO
    MMSEN


    It should check each letter of the 1 name and give the permutation and combination with each letter in all the other 4 names.


    Thank You
    Last edited by zaveed; 04-05-2013 at 03:33 PM. Reason: Formatting

  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: Permutation & Combinations of Names of different lengths

    ...with no repeats, ever? THe same 5 letters would not occur together, that's permutations. For instance, when the macro got to the SECOND letter "L" in Michelle, it would basically add nothing since all those permutations would have been created on the first "L".
    _________________
    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
    12-04-2012
    Location
    india
    MS-Off Ver
    2021
    Posts
    45

    Re: Permutation & Combinations of Names of different lengths

    Quote Originally Posted by JBeaucaire View Post
    ...with no repeats, ever? THe same 5 letters would not occur together, that's permutations. For instance, when the macro got to the SECOND letter "L" in Michelle, it would basically add nothing since all those permutations would have been created on the first "L".
    Hi,

    Yes that correct, if its the same letter then it would have already been listed in the output.


    Thanks

  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: Permutation & Combinations of Names of different lengths

    With no repeats, that means AMMSS in the list would mean that MMSSA could not exist later, that's the same 5 letters in another order, so it's the same permutation. With that understanding, these two macros will do it:

    Please Login or Register  to view this content.

    You can add this line near the bottom of the main macro to sort the resulting list:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-04-2012
    Location
    india
    MS-Off Ver
    2021
    Posts
    45

    Re: Permutation & Combinations of Names of different lengths

    Thank YOU. it worked.

    Thanks
    Zaveed

+ 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