Create unique list from two columns
I read an article Merging Lists To A List Of Distinct Values at CPearson. The article describes code that you can use to merge two lists into a third list and prevent duplicate entries in the resulting list, using VBA to create a macro.
Here is a solution to create a unique list from two columns without using VBA. To the right are two pictures of two example lists (List1 and List2).
Named ranges
I created a named range for List 1: List1 (A2:A5)
I created a named range for List 2: List2 (C2:C6)
The picture below shows the unique list and the unique distinct list.
Unique values
Here is the formula in A10:
=IF(ROWS(A9:$A$9)<=SUM(IF(COUNTIF(List1, List1)+COUNTIF(List2, List1)=1, 1, 0)), INDEX(List1, MATCH(0, IF((COUNTIF(List1, List1)+COUNTIF(List2, List1))*NOT(COUNTIF(A9:$A$9, List1))=1, 0, COUNTIF(List1, List1)+COUNTIF(List1, List2)), 0)), INDEX(List2, MATCH(0, IF((COUNTIF(List2, List2)+COUNTIF(List1, List2))*NOT(COUNTIF(A9:$A$9, List2))=1, 0, COUNTIF(List2, List2)+COUNTIF(List1, List2)), 0))) + CTRL + SHIFT + ENTER copied down as far as necessary.
Unique distinct values
Here is the formula in C10:
=IF(ROWS(C9:$C$9)<=SUM(1/COUNTIF(List1, List1)), INDEX(List1, MATCH(0, COUNTIF(C9:$C$9, List1), 0)), INDEX(List2, MATCH(0, COUNTIF(C9:$C$9, List2), 0))) + CTRL + SHIFT + ENTER copied down as far as necessary.
How to customize the formula to your excel workbook
Change the named ranges. If your unique list starts at F3, change C9:$C$9 (or A9:$A$9) in the above formula to $F$2:F2.
Download excel sample file for this tutorial.
unique-list-from-two-columns.xls
(Excel 97-2003 Workbook *.xls)
Functions in this article:
IF(logical_test;[value_if:true];[value_if_false])
Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE
ROW(reference) returns the rownumber of a reference
ROWS(array) returns the number of rows in a reference or an array
ADDRESS(row_num,column_num)
creates a cell reference as text, given specified row and column numbers
INDIRECT(ref_text,[a1])
Returns the reference specified by a text string
SMALL(array,k) returns the k-th smallest row number in this data set.
This blog article is one out of thirteen articles on the same subject "unique".
How to extract a unique distinct list from a column in excel
Extract a unique distinct list from two columns using excel 2007 array formula
Extract a unique distinct list from three columns in excel
Extract distinct unique sorted year and month list from a date series in excel
Create a unique distinct list from a date range in excel
Unique values from multiple columns using array formulas
Extract a unique distinct list sorted from A-Z from range in excel
Sort a range by occurence using array formula in excel
Filter unique distinct values from two ranges combined in excel 2007
Create a unique list and sort by occurrances from large to small
Unique list to be created from a column where an adjacent column has text cell values
Create unique list from column where an adjacent column meets criteria
How to create a unique distinct list where other columns meet two criteria
Related posts:
- Extract a unique distinct list from two columns using excel 2007 array formula
- Comparing two columns and sum unique values using array formula in excel
- Extract a unique distinct list from three columns in excel
- How to create a unique distinct list where other columns meet two criteria
- Extract largest values from two columns using array formula in excel
- Count unique distinct values in two columns with date criteria in excel
- Extract a list of duplicates from two columns combined using array formula in excel
- Count unique distinct values in three columns combined in excel
- Count unique distinct values in two columns in excel
- Merge two columns into one list in excel




June 8th, 2009 at 1:36 pm
Hi,
I've been searching for articles to help me to identify unique data across multiple Excel columns, and yours is the closest I have found. However, it seems to deal with only two (2) columns at a time. Is it expandable to cover more than two, in particular where the columns are not adjacent?
What I have is a grid of results:
Cols A, B, C reference result set 1 (with the potentially duplicate data in Col C)
Cols D, E, F reference result set 2 (with the potentially duplicate data in Col F)
and so on, with potentially result sets. The pracical number of rows involved is likely to be no more than 500.
What I need to do is to count all the unique entries in Col C, Col D, Col as a combined set, such that if Col C has data "abc", and Col also has the same data, then the data is only counted once. (I don't actually need to generate a new list of the unique data, but if that is a required stage in the calculation it is not a problem.) Note that can be any value, but is likely to not exceed 500 columns.
Could you advise me if there is a specific, formulaic (not VBA) solution to the problem? If so, could you provide a clue to solving it?
Many Thanks,
Nigel Edwards.
June 9th, 2009 at 3:10 pm
Thanks for commenting!
Interesting question, I have to think about this question for a while...
June 11th, 2009 at 10:16 pm
I created an array formula that counts unique distinct values in three different ranges.
http://www.get-digital-help.com/2009/06/11/count-unique-distinct-values-in-three-columns-combined-in-excel/
September 17th, 2009 at 10:36 am
hi, i'm curious on this solution.
Is there a simpler/shorter formula to extract non-duplicate entries?
output shall be BB and EE (non-duplicates on both columns).
September 18th, 2009 at 1:02 pm
I have updated this blog post. I think the formula is somewhat shorter and uses less named ranges.
September 19th, 2009 at 2:09 am
xcellent!!! thanks!!