+ Reply to Thread
Results 1 to 13 of 13

Extracting all unique combinations of elements across three columns

  1. #1
    Registered User
    Join Date
    06-09-2014
    Posts
    39

    Extracting all unique combinations of elements across three columns

    Hello,

    I have a file with two important tabs. "compiler" and "annual summary".

    In compiler there is a bunch of data entered into columns. Three of these columns are "Year", "Location" and "Crude Type". The data is collected on a monthly basis.

    I wish to write a program that, among other things, will first (after naming the ranges) as "year", "Location" and "Crude", respectively, all unique combinations across the three columns in the compiler sheet into the annual summary sheet with the elements still organized into separate columns.

    For example,

    In the "year" column, there are elements "2012" & "2013", in the "location column" the elements "regina" and "Prince Rupert", among others exist, and in "crude" there are entries of "WCB" and "OCC" among others. Lets say they appear like this:

    2012 Prince Rupert WCB
    2012 Prince Rupert WCB
    2013 Regina OCC
    2013 Prince Rupert WCB

    In the annual summary tab I want the output to be:

    2012 Prince Rupert WCB
    2013 Regina OCC
    2013 Prince Rupert WCB

    In my actual sheet there are many other values that exist in these columns, and I have attached a sample excel sheet as a more clear demonstration. Any help in creating a code that will accomplish this task is greatly appreciated. I have put 0s as placeholders where other data would be in the original file.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,043

    Re: Extracting all unique combinations of elements across three columns

    How does this work for you?

    there might be neater solutions (without helper rows).
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,043

    Re: Extracting all unique combinations of elements across three columns

    The frst reply was for an array formula (set by CTRL+ SHIFT + ENTER). This is a regular (Enter) formula solution...
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-09-2014
    Posts
    39

    Re: Extracting all unique combinations of elements across three columns

    Hi,

    This does help, but there is still one glitch. It works fine for outlining the year and location, but I can't separate the crude type as well.

    So using this method, it is easy to extract the first four characters in the unique combinations as being the year (using the left function), but then there are also the location AND crude type variables to be retrieved.

    So, for example, my first entry in the compiler tab that results from using the Index,Match,Countif formula (which you put in column J) is actually supposed to be:

    2012 Regina WCB

    Another unique entry is:

    2013 Montreal WCB

    Not sure how to use the Left or Right formulas to extract what i need given that the number of characters in the elements of the location and crude type columns change throughout the array.

    Any thoughts?

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,043

    Re: Extracting all unique combinations of elements across three columns

    Dohh !!

    I misread your instruction. Give me 5 minutes..

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,043

    Re: Extracting all unique combinations of elements across three columns

    Is this more like it?
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-09-2014
    Posts
    39

    Re: Extracting all unique combinations of elements across three columns

    This is perfect. Thank you so much for your help.

    Now if only I could learn how to code these things into VBA. I just started trying to learn haha. It's proving to be quite a task!

    Thanks again.

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Extracting all unique combinations of elements across three columns

    hi bakeraj256, VB option, press "Run" button on Annual Summary sheet or run code "test"
    Attached Files Attached Files

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,043

    Re: Extracting all unique combinations of elements across three columns

    Well, now you have two answers for the price of one... if this closes out your questions, can you mark the thread as soled and (preferably) say thanks to all who helped by clicking the "Add Reputation" button at the foot of their post(s).

  10. #10
    Registered User
    Join Date
    06-09-2014
    Posts
    39

    Re: Extracting all unique combinations of elements across three columns

    Thank you both.

  11. #11
    Registered User
    Join Date
    06-09-2014
    Posts
    39

    Re: Extracting all unique combinations of elements across three columns

    Yes, I can definitely use Glenn's suggestion.

    Am working now on adapting Watersev's file to the setup of the actual file I am working on.

    Will do as asked in Glenn's 16:41pm (Ontario time) post.

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,043

    Re: Extracting all unique combinations of elements across three columns

    As good as your word... Thanks.

  13. #13
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Extracting all unique combinations of elements across three columns

    Try this Array Formula which requires confirmation with Ctrl+Shift+Enter instead of just Enter.
    On Annual Summary Sheet, in A2
    Please Login or Register  to view this content.
    and then drag across and down until you get blank cells.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

+ 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. Finding unique combinations of 2 columns
    By Scooternm in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-23-2020, 12:41 PM
  2. [SOLVED] Unique Combinations from 4 Columns
    By ayvee0 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-12-2013, 06:44 PM
  3. Finding unique combinations across 3 columns using a function
    By Hdim in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 05-31-2013, 07:17 AM
  4. Counting Unique Elements Across Multiple Non-Consecutive Columns
    By Lemguin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2013, 10:07 PM
  5. Help Needed - Extracting Columns Duplicate and Unique Elements
    By sanjeevpandey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-05-2012, 05:59 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