+ Reply to Thread
Results 1 to 10 of 10

Getting all possible combinations of two tables/columns

  1. #1
    Registered User
    Join Date
    04-26-2017
    Location
    Göttingen, Germany
    MS-Off Ver
    Office 2016
    Posts
    5

    Getting all possible combinations of two tables/columns

    Hi,
    I have a probably very easy problem but I can't find a solution probably because I don't know the right excel vocabularies.

    I have two columns or tables (doesn't matter), one with names and one other with actions like:

    names
    --------
    James
    Nathaly
    May
    ...

    actions
    ---------
    cleaning windows
    cleaning floor
    washing
    ...

    now I wont to get a new table where I have all possible combinations of the entries from the both different tables/columns like:

    names ... | actions
    -----------------------------------------
    James .... | cleaning windows
    James .... | cleaning floor
    James .... | washing
    Nathaly .. | cleaning windows
    Nathaly .. | cleaning floor
    Nathaly .. | washing
    May ....... | cleaning windows
    May ....... | cleaning floor
    May ....... | washing
    ...

    I was googling for adjacency lists and all possible combinations between two lists but can't find anything relating to my issue

    If anyone has a solution I would really appreciate that.
    Last edited by flero94; 04-26-2017 at 08:01 AM.

  2. #2
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,279

    Re: Getting all possible combinations of two tables/columns

    If name in "A1:A3" & action in "B1:B3"
    Enter formula in "F1"
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Copy Paste F1 formula down until empty cell.


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  3. #3
    Registered User
    Join Date
    04-26-2017
    Location
    Göttingen, Germany
    MS-Off Ver
    Office 2016
    Posts
    5

    Re: Getting all possible combinations of two tables/columns

    Thanks for the fast answer! I thought I exactly did how you mentioned but I always get the error message "there is a problem with this formula".

    -I have my names in A1:A3
    -I have my actions in B1:B3
    -I copied the code in F1
    -And I copied that few lines down.

    Screenshot 2017-04-26 14.17.08.png

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Getting all possible combinations of two tables/columns

    Please attach a sample excel file
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Registered User
    Join Date
    04-26-2017
    Location
    Göttingen, Germany
    MS-Off Ver
    Office 2016
    Posts
    5

    Re: Getting all possible combinations of two tables/columns

    Here is the link to the example file! Thank you a lot for your help
    https://www.dropbox.com/s/xh5llp07mw...mple.xlsx?dl=0

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,741

    Re: Getting all possible combinations of two tables/columns

    Another way.

    Edited first formula below. Should be COUNTA($B$2:$B$20)

    Row\Col
    A
    B
    C
    D
    E
    1
    names actions names actions
    2
    James cleaning windows James cleaning windows
    3
    Nathaly cleaning floor James cleaning floor
    4
    May washing James washing
    5
    Nathaly cleaning windows
    6
    Nathaly cleaning floor
    7
    Nathaly washing
    8
    May cleaning windows
    9
    May cleaning floor
    10
    May washing
    11
    12


    In D2 this formula filled down until you get blanks.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and in E2
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 04-26-2017 at 04:04 PM.
    Dave

  7. #7
    Registered User
    Join Date
    04-26-2017
    Location
    Göttingen, Germany
    MS-Off Ver
    Office 2016
    Posts
    5

    Re: Getting all possible combinations of two tables/columns

    Thanks for the help now it is working for me.

    Because I have a german Office version it was necessary to translate all commands (even the if command ). Also I had to switch the "," to ";" maybe it's also a language thing or it is just a configuration thing. Probably that was the issue with the first answer as well. Below I post the german code maybe it helps anyone:

    For D2
    Please Login or Register  to view this content.
    For E2
    Please Login or Register  to view this content.
    Thanks again, you are were a greate and fast help.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,741

    Re: Getting all possible combinations of two tables/columns

    flero94 my apologies.

    I failed to note German location. If I would have uploaded an Excel workbook with the solution Excel would have handled the regional settings. I am not sure of the translation, though.

    My bad.

    Glad to hear you got it to work. Thank you for the feedback.

  9. #9
    Registered User
    Join Date
    04-26-2017
    Location
    Göttingen, Germany
    MS-Off Ver
    Office 2016
    Posts
    5

    Re: Getting all possible combinations of two tables/columns

    No worries, it was not your fail. The actual problem is that Microsoft started to translate everything. It would be so easy just to use the English words. Everyone understand them and all other programs / programming languages are using them. In the last time I even learned new german words because microsoft was translating them, but everyone was using the english ones before.

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

    Re: Getting all possible combinations of two tables/columns

    Here's another way (with file attached so that you can see the translated formulae). I put 4 names in A2:A5 and the three actions in B2:B4, then this formula in D2:

    =IF(ROWS($1:1)>COUNTA(A:A)*COUNTA(B:B),"",INDEX($A$2:$A$5,INT((ROWS($1:1)-1)/COUNTA(B:B))+1))

    and this formula in E2:

    =IF(D2="","",INDEX($B$2:$B$4,MOD(ROWS($1:1)-1,COUNTA(B:B))+1))

    The formulae were then copied down to row 25, i.e. far more than is required. If you have another name, change the $A$2:$A$5 in the first formula.

    Hope this helps.

    Pete

    P.S. When you type a function name in Excel as part of a formula and then press Enter, Excel has to try to make sense of the string that you have typed in. In parsing that string, Excel will look for the function names and translate them into a token (some number), which then makes it easier to translate the function names into words for different languages. So, if I have a formula with INDEX in it, that will be stored as a token, then if the workbook is opened in a French language version, the equivalent name for INDEX will appear for that French user.

    The use of commas vs semicolons is governed by the List Separator as defined in a user's Regional Settings. Generally, in Continental Europe a comma is used instead of a full-stop to denote a fractional decimal number, e.g. 3,142 to denote PI. Consequently, a comma can't be used as a list separator as decimal values would confuse the parser, and so a semicolon is used instead.
    Attached Files Attached Files

+ 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: 0
    Last Post: 03-03-2015, 11:43 AM
  2. Replies: 3
    Last Post: 01-22-2013, 07:11 PM
  3. How to get all possible combinations of 4 columns into a 5th column?
    By sami770 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-22-2012, 02:39 PM
  4. How to get all possible combinations of two columns into a third?
    By sami770 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-21-2012, 12:57 AM
  5. Create all 2,3,4,5 etc combinations of columns out of X number of columns
    By sans in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-11-2012, 03:51 PM
  6. Get all combinations from 2 columns?
    By racerxar in forum Excel General
    Replies: 6
    Last Post: 09-23-2011, 12:27 AM
  7. Possible Combinations of Columns
    By thefreshbasil in forum Excel General
    Replies: 9
    Last Post: 01-17-2009, 12:05 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