+ Reply to Thread
Results 1 to 10 of 10

Random combination from 2 colums

  1. #1
    Registered User
    Join Date
    08-24-2015
    Location
    Singapore
    MS-Off Ver
    2007, 2013, 2016
    Posts
    20

    Random combination from 2 colums

    Hi, is there any possible way (preferably with macros) that I could generate a combination between 2 columns of values?
    E.g.

    Column A: Apple, Orange, Pear, Jackfruit
    Column B: Monkey, Tiger, Lion, Leopard, Chimpanzee, Gorilla

    Generated column: Apple-Tiger, Orange-Lion, Pear-Monkey, Jackfruit-Gorilla, Orange-Leopard, Pear-Chimpanzee
    *Requirements:
    1. The number of combinations generated should be the same as the number of rows in the column (A or B - whichever has more) that has values. i.e. Column B has 6, Column A has 4: Combinations generated 6
    2. Each value in A or B should appear at least once.

    Appreciate any help. Thanks!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Random combination from 2 colums

    See the workbook at https://app.box.com/s/47b28f19d794b25511be to generate all of the combinations.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-24-2015
    Location
    Singapore
    MS-Off Ver
    2007, 2013, 2016
    Posts
    20

    Re: Random combination from 2 colums

    Hi thanks for the help. But is there any way i can change it such that it does not generate all possible combinations? I do not actually require ALL possible combinations.
    e.g. if Column A has 4 values and column B has 6 values, then I will only need 6 combinations
    e.g. if Column A has 8 Values and column B has 6 values, then I will need 8 combinations.

    Thanks.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Random combination from 2 colums

    I don't understand on what basis you would choose which combinations.

  5. #5
    Registered User
    Join Date
    08-24-2015
    Location
    Singapore
    MS-Off Ver
    2007, 2013, 2016
    Posts
    20

    Re: Random combination from 2 colums

    Sorry, my bad for I wasn't clear. Please allow me to explain with 2 examples. The purpose of the combinations is to allow me to test the card types with different currencies.
    Example 1:
    Column A (4 values) Column B ( 5 values)
    Visa USD
    MasterCard EUR
    AMEX CNY
    Alipay THB
    AUD

    I just need to test each card type and currency at least once, so I don't need ALL possible combinations or permutations. So the results should be something like that:
    MasterCard-CNY, AMEX-AUD, Alipay-THB, VISA-USD, VISA-EUR. -> so 5 combinations will do since I get to test each of them at least once.

    Example 2:
    Column A (6 values) Column B ( 4 values)
    Visa USD
    MasterCard EUR
    AMEX CNY
    Alipay THB
    Unionpay
    JCB

    So the results should be something like that:
    MasterCard-CNY, AMEX-THB, Alipay-THB, VISA-USD, Unionpay-EUR, JCB-EUR -> so 6 combinations will do since I get to test each of them at least once.

    Essentially, the number of combinations will depend on the Max no. of values within Column A and B - whichever has more.

    Hope that was clear! Thank you in advance for your help!

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Random combination from 2 colums

    I can't tell what's in what column from your post, but if one column has cards and the other has currencies, the number of combinations is the product of the numbers in each column.

  7. #7
    Registered User
    Join Date
    08-24-2015
    Location
    Singapore
    MS-Off Ver
    2007, 2013, 2016
    Posts
    20

    Re: Random combination from 2 colums

    i understand that, but is it possible that the number of combinations be only the larger number of both columns?
    Column A - 4 items; Column B - 6 times => Combinations = 6
    OR
    Column A - 8 items; Column B - 3 items => Combinations = 8

    My earlier example:
    Column A______Column B
    __Visa________ USD
    MasterCard ____EUR
    _AMEX________CNY
    _Alipay________THB
    ______________AUD

    SAmple Results: MasterCard-CNY, AMEX-AUD, Alipay-THB, VISA-USD, VISA-EUR. -> so 5 combinations will do

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Random combination from 2 colums

    so 5 combinations will do
    How do you know (how do I know) which 5 combinations?

  9. #9
    Registered User
    Join Date
    08-24-2015
    Location
    Singapore
    MS-Off Ver
    2007, 2013, 2016
    Posts
    20
    Quote Originally Posted by shg View Post
    How do you know (how do I know) which 5 combinations?
    It should be a random matching. So each currency should be in ay of the 5 combinations once only and each card types should be in any of the 5 combinations at least once

    Hope that clears it up. Thanks!

  10. #10
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Random combination from 2 colums

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    http://www.excelguru.ca/forums/showt...from-2-columns

+ 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: 06-30-2015, 06:42 PM
  2. Formula - Counting a combination based in two colums
    By Jakes1991 in forum Excel General
    Replies: 6
    Last Post: 04-02-2015, 04:50 AM
  3. [SOLVED] how many cell in a row that contain certain combination from a larger combination
    By system in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 11-17-2012, 03:04 PM
  4. freeze first colums and hide one colums
    By pejoi in forum Excel General
    Replies: 2
    Last Post: 08-09-2012, 03:50 AM
  5. Formula required for comparing multiple colums to multiple colums
    By Pringgles in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-30-2012, 07:23 AM
  6. Replies: 0
    Last Post: 04-03-2006, 07:25 PM
  7. [SOLVED] random combination of letters
    By rp in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-16-2005, 10:05 AM

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