+ Reply to Thread
Results 1 to 10 of 10

Combine values from two columns to produce unique value list

  1. #1
    Registered User
    Join Date
    10-12-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    20

    Combine values from two columns to produce unique value list

    Hi,

    Loooking for some help with this please...

    I have two columns of data and would like to generate a new list showing unique combinations of those values (see attached sheet).

    Any ideas how I can do this please using a formula?

    Many thanks.

    unique list.xls
    Last edited by lucasreece; 06-28-2013 at 05:11 AM.

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Combine values from two columns to produce unique value list

    hi lucasreece. maybe a helper column in D2 copied down:
    =B2&" - "&C2

    then this array formula in E2:
    =IF(ISNA(MATCH(0,COUNTIF(E$1:E1,$D$2:$D$10),0)),"",INDEX($D$2:$D$10,MATCH(0,COUNTIF(E$1:E1,$D$2:$D$10),0)))

    ...confirmed by pressing CTRL-SHIFT-ENTER to activate the array. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL-SHIFT-ENTER you might get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    10-12-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Combine values from two columns to produce unique value list

    Many thanks for that benishiryo.

    Is there a way to achieve this without the use of a helper column?

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Combine values from two columns to produce unique value list

    well not really i think but i maybe wrong, however to avoid that array formula
    d2 down
    =IF(SUMPRODUCT(--($B$2:B2&$C$2:C2=B2&C2))=1,ROWS($A$1:A1),"")
    e2 down
    =IF(ROWS($A$1:A1)>COUNT($D$2:$D$200)-1,"",(INDEX($B$2:$B$200,MATCH(SMALL($D$2:$D$200,ROWS($A$1:A1)),$D$2:$D$200,0))&"-"&INDEX($C$2:$C$200,MATCH(SMALL($D$2:$D$200,ROWS($A$1:A1)),$D$2:$D$200,0))))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Combine values from two columns to produce unique value list

    Enter this formula in E2 and copy down:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Enter this formula in F2 and copy down:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This keeps all given names in one column and all surnames in a matching column. to produce a two column listing of unique values.

    If you want both surname and given name in one cell use:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Combine values from two columns to produce unique value list

    @newdoverman op seems to have 2003 plus what happens if 2 or more people have the same firstname?

  7. #7
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Combine values from two columns to produce unique value list

    A third criteria would be required to make the distinctions between names. An ID # for each individual would be ideal but barring that the more criteria you have for identification, the better off you are. If there was an Initial or second name, that would also help.

    The answer given solves the problem as stated. If there are other complications, they should have been stated in the original problem.

    Having said that. To bring in the surname first enter this in F2 and copy down:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Enter this in E2 and copy down to get the given names:

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Combine values from two columns to produce unique value list

    ah ah but what about
    Attached Files Attached Files

  9. #9
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Combine values from two columns to produce unique value list

    Good point!

  10. #10
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Combine values from two columns to produce unique value list

    Sometime I just get stuck in one way of looking at a problem and try to make it work. Your SUMPRODUCT formula got me thinking (after a while) "what was I thinking???" I was trying to reduce a list using a formula and couldn't get the method of what I was doing out of my head.

    This is what I really wanted to do but couldn't until you "kicked" my brain out of it's rut.

    I couldn't combine the columns in order to count the duplicates, completely forgetting about SUMPRODUCT and it took a while even after you pointed it out in your examples. Once that was overcome the rest was easy. Just choose if the results would be in 1 column (combined formulae) or in two columns with a separate formula in each.

    Crumb!! Getting old is no fun
    Attached Files Attached Files
    Last edited by newdoverman; 06-28-2013 at 03:55 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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