+ Reply to Thread
Results 1 to 7 of 7

Make unique combinations of 1 column with 1 contraint. VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    10-12-2022
    Location
    Copenhagen
    MS-Off Ver
    365
    Posts
    24

    Cool Make unique combinations of 1 column with 1 contraint. VBA

    Hi Excel geniuses

    I need help with generating unique combinations of digit values in column "A":

    A ("Input")
    0.660
    0.742
    0.825
    0.990
    1.155
    1.237
    1.253

    I have attached my workbook. I have used a vba code from a teaching webside, which worked out ok.
    The result is marked with light red in my workbook.

    However, I have encountered 3 problems:
    1. The combinations are stored together in one single cell. Once outputted, I would like them separated in different columns, so I can make a sum total of the combinations. The Blue table is my end goal.
    2. The VBA code does not allow each input from the yellow column ("A") to be used more than once. I need each width to be able being used more than once.
    3. I would like a constraint inside the VBA code, so only combinations with sum total less than (=<) 3.85 are generated. Is this possible?

    I made The Blue table manually to illustrate my end goal. I hope the task makes sense.

    1664998082208.png
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,122

    Re: Make unique combinations of 1 column with 1 contraint. VBA

    You have 365. Use TEXTSPLIT to separate the entries using comma as the separator.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-12-2022
    Location
    Copenhagen
    MS-Off Ver
    365
    Posts
    24

    Re: Make unique combinations of 1 column with 1 contraint. VBA

    Hi TSM

    Thanks for your reply.

    Yes that is a good alternative option. However, I am really hoping for VBA solution that can also solve my second problem

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,122

    Re: Make unique combinations of 1 column with 1 contraint. VBA

    Use VBA to put the TEXTSPLIT formula where you want it. Then convert to values. Let Excel do the work.

  5. #5
    Registered User
    Join Date
    10-12-2022
    Location
    Copenhagen
    MS-Off Ver
    365
    Posts
    24

    Re: Make unique combinations of 1 column with 1 contraint. VBA

    Make sense, thanks! I put it in as a Worksheet.function with VBA.

    On the other hand, can you be of any help with the second or third problem? How can i get combinations with each input included several times? for instance: 0.742 - 0.742 - 0.825 - 0.825

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,396

    Re: Make unique combinations of 1 column with 1 contraint. VBA

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not told us about this. You are required to do so.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important: https://excelguru.ca/a-message-to-forum-cross-posters/

    (Note: this requirement is not optional. As you are new here, I have done it for you this time: https://www.mrexcel.com/board/thread...h-vba.1219121/)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  7. #7
    Registered User
    Join Date
    10-12-2022
    Location
    Copenhagen
    MS-Off Ver
    365
    Posts
    24

    Re: Make unique combinations of 1 column with 1 contraint. VBA

    Hi Ali

    Yes, please accept my apologies. I was informed about this issue in a pop-up window on the site and I made an attempt to edit my post and include the link. I must not have saved my post probably or something. Again, thank you for the clarification.

    Any help would be appreciated.

+ 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: 1
    Last Post: 03-29-2020, 03:31 PM
  2. [SOLVED] Matching unique column combinations of data with VBA
    By insomniac53 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-03-2015, 07:48 PM
  3. [SOLVED] Pull unique two column combinations and skip particular value
    By volfied in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-30-2013, 11:02 AM
  4. Make and regularly update a list of all combinations of two lists of unique values
    By Sherelle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-19-2012, 07:21 PM
  5. How to populate multiple column listbox with unique combinations only
    By shuvajit in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2012, 12:37 AM
  6. Replies: 7
    Last Post: 02-11-2011, 06:58 AM
  7. Generating combinations from a column of unique numbers
    By mistermat in forum Excel General
    Replies: 1
    Last Post: 08-31-2008, 06:54 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