+ Reply to Thread
Results 1 to 14 of 14

Combination letters in word

  1. #1
    Registered User
    Join Date
    08-02-2022
    Location
    france
    MS-Off Ver
    2016
    Posts
    3

    Combination letters in word

    hello,

    I am trying to find all the possible letter combinations of a word.
    But I want the word to keep the same length, just the letters that move to form all the combinations

    For example :

    my_word : hello
    combinations : hello, helol, heoll, hoell, hlelo, ...

    Thanks for your help

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

    Re: Combination letters in word

    From your example you want permutations, not combinations.

    How many letters can your words have?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    08-02-2022
    Location
    france
    MS-Off Ver
    2016
    Posts
    3

    Re: Combination letters in word

    Quote Originally Posted by 6StringJazzer View Post
    From your example you want permutations, not combinations.

    How many letters can your words have?
    Hi, thanks for your reply

    I hesitated between the two because I only want the combinations/permutations of the same number of letters as the word.
    For the number of letters, I would like to be able to enter any word (from 2 to n letters).

    The permutations/combinaisons for a word of 3 letters are (for example):
    word : cat
    result : cat, cta, tca, tac, act, atc

    Thanks for your help.

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

    Re: Combination letters in word

    Those are permutations. Combinations would include ccc, ctt, aaa, acc...

    There might be a formula solution to this but may require VBA. I can get back a little later today. Someone else may respond sooner.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Combination letters in word

    I remembered that I played around with a workbook that someone attached at one time or another.
    It was still hanging around on my computer so here is the code.
    I am not the brain behind this so if you need changes made, you'll have to do it or someone else needs to jump in.
    Jeff might come up with a better solution.
    If you end up with doubles, let us know or use the code at the end. You can use that macro anyway as it does not do any harm if no doubles found.

    All three go in a regular module and you call it with the "GetString" macro.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    https://socratic.org/questions/how-d...ions-of-a-word
    Last edited by jolivanes; 08-03-2022 at 12:09 PM. Reason: Added info
    Experience trumps academics every day of the week and twice on Sunday.

  6. #6
    Forum Contributor
    Join Date
    07-21-2021
    Location
    Norfolk, UK
    MS-Off Ver
    Excel 2003, 2007, 2013, 2019
    Posts
    212

    Re: Combination letters in word

    Yes, this code works well. However, your words are not permitted duplicate letters.

    I processed my own name 'stephen' and the output generated 2520 duplicates out of the total 5040.
    Regards,

    Stephen

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Combination letters in word

    If you change an "e" to an "x", do you still get duplicates?

  8. #8
    Forum Contributor
    Join Date
    07-21-2021
    Location
    Norfolk, UK
    MS-Off Ver
    Excel 2003, 2007, 2013, 2019
    Posts
    212

    Re: Combination letters in word

    No, if all letters are different the code works well - no duplicates.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Combination letters in word

    There bound to be duplicates with the same letters.
    See if you get any duplicates by using "EEEEEEE"

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

    Re: Combination letters in word

    Quote Originally Posted by swaatacba View Post
    Yes, this code works well. However, your words are not permitted duplicate letters.

    I processed my own name 'stephen' and the output generated 2520 duplicates out of the total 5040.
    First, a Sub is provided to remove duplicates.

    Seeing as though you are not the OP, we should find out if this solution meets the needs of this particular thread.

  11. #11
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,408

    Re: Combination letters in word

    Quote Originally Posted by swaatacba View Post
    Yes, this code works well. However, your words are not permitted duplicate letters.

    I processed my own name 'stephen' and the output generated 2520 duplicates out of the total 5040.

    I would think the algorithm is correct.
    With a word of 7 letters, 2 of which are the same, there are 7!/2! = 2520 possibilities.

  12. #12
    Forum Contributor
    Join Date
    07-21-2021
    Location
    Norfolk, UK
    MS-Off Ver
    Excel 2003, 2007, 2013, 2019
    Posts
    212

    Re: Combination letters in word

    Quote Originally Posted by supersabers View Post
    For example :

    my_word : hello
    combinations : hello, helol, heoll, hoell, hlelo, ...
    Please note that the originator included this example - with duplicate l's. We await a response from him as to what is required.

  13. #13
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,516

    Re: Combination letters in word

    Jeff
    Re: "Seeing as though you are not the OP,"
    I guess I better pay attention. Had not even noticed that.

  14. #14
    Registered User
    Join Date
    08-02-2022
    Location
    france
    MS-Off Ver
    2016
    Posts
    3

    Re: Combination letters in word

    Thank you all for your responses !

    Quote Originally Posted by swaatacba View Post
    Please note that the originator included this example - with duplicate l's. We await a response from him as to what is required.
    To answer this question, yes indeed it is possible to have a word with several times the same letter.
    I want the permutations to give each time a word of the same size with the same letters but arranged in all possible combinations.

    Thank you all for your help.

+ 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: 9
    Last Post: 09-01-2020, 10:49 AM
  2. combination of numbers or letters
    By torjan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2014, 06:20 PM
  3. [SOLVED] Removing letters from text & letters combination
    By benoj2005 in forum Excel General
    Replies: 5
    Last Post: 02-26-2014, 11:20 AM
  4. [SOLVED] Find word using combination of given letters
    By net.rider in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-02-2012, 04:38 AM
  5. Sum numbers with certain combination of letters
    By sizcorx in forum Excel General
    Replies: 1
    Last Post: 10-09-2010, 09:10 PM
  6. finding out the combination of letters!
    By via135 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-13-2006, 01:12 AM
  7. [SOLVED] random combination of letters
    By rp in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-16-2005, 10:05 AM

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