Comments on: How to get a list of unique and distinct values in Excel

If you want to get a list of unique values in a column, this tutorial offers a number of formulas and will teach you how to tweak them for different datasets. You will also learn how to quickly get a distinct list using Excel's Advanced Filter, and how to extract unique rows with Duplicate Remover. Continue reading

Comments page 4. Total comments: 171

  1. I need to get the list of duplicates in Column B and it should return its value and the value in Column A.

  2. Hello,
    I have two Worksheets---WS1 Customer column A(match)& Customer Number B(return value) ....WS2 Customer column E ...WS 2 Column Q (formula)- I need a formula that will match WS2 Column E to Column A WS1 and return value of column B WS1

    Thank you in advance!!

    1. To add the columns in WS 1 Customer are not alphabetized. So, therefore other index match formulas I am using, are not working.

  3. Hello Expert
    Is there a way to list distint text value with criteria? Example in the following

    G2:G20 - Emloyee (Text & Number)
    E2:E20 - Work Week (number only)

    is there a way for me employee name in work week 30 to list like below

    WW=30 (Criteria)
    Employee
    CU110
    1267
    NP230
    27786

  4. Your explanations and examples are very impressive. One issue that confused me was how to propagate the array formulas. I found I had to enter the formulas and propagate them before making them arrays. I then had to individually make the formula of each cell an array with CTRL+SHIRt+ENTER.

    Did I miss something in the examples explanations?

    I am also a programmer so I may tend to use VBA when the formulas become too subtle. Maybe your readers may want to consider this as well. The macro recording feature may be another approach as well.

    Best regards.

  5. So I'm trying to utilize the formula function to get it to essentially do it automatically but every time I put in the formula it always kicks back telling me the Cells are empty do I still have to copy and paste in the values? or is there some way that I can have it pull the values from the cells and only display the unique values on its own?

  6. Hi Svetlana,

    I am able to extract unique list as per your instructions. Thanks.

    Could you please help me sort the unique list that is generated?

    1. Hi Ravi,

      You will have to replace formulas with values first (Paste Special > Values), and then you can use the Excel Sort option (Data tab > Sort & Filter group, A-Z button).

  7. this doesn't work, I get banana for every output, why is this?

    1. Hi Andy,

      What formula are you using?

  8. Hello!

    Thank you so much for explaining how to do this. I have two questions.

    Currently, the range I'm using as my source is a named column in a named table in a separate sheet. I've had no problems referring to the source list in the "distinct values ignoring blanks" formula, using the format TableName[Column] in place of each instance of $A$1:$A$20 in the example. However, what I am wanting to do is use this formula in a validation rule on another sheet, so that I can have an automatically populated dropdown list based on TableName[Column]. Of course, simply doing =INDIRECT(TableName[Column]) returns the entire list, which is full of blanks and duplicates, but removing the IFERROR portions of the formula and trying to incorporate INDIRECT(TableName[Column]) does not seem to be working either. Is there anything I can do to modify the formula to achieve my goal?

    If what I described above is not possible, I've thought of an alternative, but that brings me to my second question. If I were to use the "distinct values ignoring blanks" formula as a formula in Sheet 2, define the extracted list of distinct values from TableName[Column] as TableName2[Column1], and then use =INDIRECT(TableName2[Column1]) as a validation rule for Sheet 3, would there be any way to have TableName2[Column1] automatically update/add to itself...? The thing is, I know I will be adding more values to TableName[Column] from Sheet 1 and I'm hoping I can have an up-to-date list of all of its distinct values available to me at any given time. I really have no estimate of just how many values that would be. By any chance, is it possible for the formula to copy itself to the adequate number of cells when a change is detected in the range it depends on, ideally in a way that does not require me to manually update the reference of the validation rule every time? Or something similar to that, maybe? Ah, I hope that makes sense.

    Thank you in advance!

  9. hi,
    How can i modify the above formulas in the article to add a second criteria on the same range that i want to extract ,
    ex: the range is numbers like , 50001, 50002, 50003, 100001,20001,
    i want to extract only the number that start with 5000 but unique with no duplication.

    Thanks in advance.

  10. Hello,

    I have a large list of names from a survey where the names were inputted differently each time. Many issues involved differences of case sensitivity as well as additional spaces. I have used an =UPPER(TRIM(x)) function to remedy these issues, but I cannot reference the resulting cells for the advanced filter function to extract unique names. Is there a way to remedy this problem?

    Additionally some problematic cells contain issues like this:

    Smith JosephJohn
    Smith Joseph John

    Is there a way to identify and fix these cells faster than manually looking at each one?

    Thank you

    1. Mischa:
      Sometimes the condition of the data requires you to do what you can with the help of the software and then there is nothing to do except go through the data line by line and clean it up.

  11. How to find unique transaction count
    For example

    1 Apr 3018 there is so many sales, I have to count to how many customer we sold the product ( unique customer) based on the date of Sales

  12. Hi,

    I've used your formula and works just fine.
    From 1000 rows where only 337 are filled in with information, I get 62 distinct values.
    However, there's a big problem. I got those 337 lines in a separate Excel sheet just to verify and after I have selected "Remove Duplicates" manually, I saw that I was supposed to get 65 values.

    The 3 values (cells) that are NOT present have the longest character count (295,319 and 359 characters).

    Is there a limitation? Why is it not retrieving these 3 lines?

    I'm using the correct formula:

    {=IFERROR(INDEX($A$2:$A$1000, MATCH(0, COUNTIF($B$1:B1, $A$2:$A$1000), 0)), "")}

    Thank you,
    Horatiu

  13. How to create a unique & sorted distinct list where other columns meet Multi criteria?
    Cat1 Cat2 List
    BB A 4
    AA B 2
    AA A 1
    BB C 2
    CC A 2
    BB B 4
    BB A 2
    BB B 3
    CC C 1
    CC A 5
    BB A 3
    BB B 4
    AA A 2
    BB B 5
    BB A 4

    Criteria in Cat1: BB or CC
    Criteria in Cat2: A

    Result:

    Created List
    2
    3
    4
    5

  14. Hi Svetlana,

    I'm trying to get all distinct values in a secondary sheet but I need the formula to also have 2 conditions in it, as I have a huge list with at least 6 prices for several venues.
    I've been trying on my own but couldn't figure it out yet, seems index&match formulas are giving me bit of a headache.

    Can you give an example of how conditions could be included in it?

    Thanks

  15. Hi Svetlana, thanks for this!

  16. Hi, about the Extract distinct values ignoring blanks, is there a way to expand this formula (without neeeding to use vba, pivot etc) to include checking for one or more criteria in other columns, before returning the names. I uploaded the workbook. In it, there are 2 resulting tables, each showing distinct names. 'Month' column is for reference only, please ignore it. Non-array formula, if possible, will be best.

    https://drive.google.com/open?id=1l7mGduN0lzaSjLXzkY40H_gzMAC_gqUx

    Thank you!

    1. Hi Eddie,

      To my best knowledge, it can only be done with an array formula, and I have added it to your workbook. However, the Active list returned by the formula is different from your resulting table because a few names are marked as both Active and Non-active.

      1. Hi Svetlana, thanks for your reply. I realized I had previously set the file in gdrive to be read-only. Do you mind sending the updated workbook to my email. Thanks again!

        1. Eddie,

          I've uploaded it to our web-site in case someone else is looking for a similar solution. You can download the workbook here (formula cells are highlighted in blue).

  17. hi
    thats nice

  18. Dear Svetlana,

    What if I want to add a second filter to an array formula? Problem occurs with the expanding part of the formula, let's assume I have the following Data:

    Dimension Name
    0.80 Sur
    0.80 Sur
    0.80 Sur
    0.80 Sur
    0.80 Sur
    0.80 Sur
    0.80 Sur
    1.30x0.70 Sur
    1.60x0.70 Sur
    0.80 Sur
    0.90 Sur
    0.80x0.36 EM4
    0.80x0.36 EMC1
    0.90x0.36 EMC1
    1.00x0.36 EMC1
    0.60 Canto
    0.80 Canto
    1.00x0.75 Canto
    1.20x0.75 Canto
    1.20x0.75 Canto
    1.20x0.75 Canto
    1.00x0.76 Canto

    What I want to obtain is a list of unique values of dimensions per Name, that is to say, the unique dimension values that share a same name. Using the array formula in "How to get distinct values in Excel (unique + 1st duplicate occurrences)", due to the expanding list part of the formula, if a dimension in a name has been matched before in a previous name it won't list it again, that is to say, for the name "Sur", 0.80 will list as a unique value, however for the Name "Canto", 0.80 won't list since it was already listed on "Sur". How could I modify the formula so that it creates a new expanding list each time a new Name appears on the list?

    Cheers and thank you.

    1. Hello,

      If we suppose that your table starts with cell A1, please try to do the following:

      1. Enter the formula below in cell C2:

      =IFERROR(INDEX($A$2:$A$23, MATCH(0, INDEX(COUNTIFS($C$1:C1, $A$2:$A$23,$D$1:D1, B$2:$B$23), 0, 0), 0)), "")

      2. Enter this formula in cell D2:

      =IFERROR(INDEX($B$2:$B$23, MATCH(0, INDEX(COUNTIFS($C$1:C1, $A$2:$A$23,$D$1:D1, B$2:$B$23), 0, 0), 0)), "")

      3. Select the cells where you've entered the formulas and copy them down to the other cells in the columns by dragging the fill handle (a small square at the lower right-hand corner of the selected cell).

      Hope this will help you with your task.

  19. Hi Svetlana,

    Good day. Thank you for the article. It really helped me a lot.

    I just have one problem here in my excel sheet. I get that in your examples, the list exist only on one column. What if my list consist of an array of cells. Please refer to the table below. I have 2 columns of data and I want to make a list of all the data. I hope you could help. Thanks!

    DATA 1 DATA 2 RESULT
    A1 B1 A1
    A2 B1 A2
    A2 B1 A3
    A3 B2 B1
    A3 B2 B2
    A3 B2

    1. Hello,

      I'm afraid there's no easy way to solve your task with a formula. Using a VBA macro would be the best option here.

      However, since we do not cover the programming area (VBA-related questions), I can advice you to try and look for the solution in VBA sections on mrexcel.com or excelforum.com.

      Sorry I can't assist you better.

  20. Hi Svetlana,

    what is the role of &"" after a range in countif formula? When I evaluate the formula I can see the difference but I would like to understand how it works.

  21. Hi Svetlana,

    Instead of finding unique names in a column, I need to find unique names in multiple columns. Is there an easy way?

  22. Thank you for the info.
    I would like to find out, for "Extract distinct values in a column ignoring blank cells", how can I sort the list by alphabetical order.

    regards.

    1. Hello, Wendy,
      For me to understand the problem better, please send me a small sample workbook with your source data and the result you expect to get to support@ablebits.com. Please don't worry if you have confidential information there, we never disclose the data we get from our customers and delete it as soon as the problem is resolved.
      Please also don't forget to include the link to this comment into your email.
      I'll look into your task and try to help.

  23. Thank you for the information.
    I would like to know how to "Extract distinct values in a column ignoring blank cells" and also arrange them in alphabetically order.

    Many thanks in advance!

  24. Hi, thank you for your instructions and help!
    I'm wondering if you know of a way to return multiple corresponding values from more than one column (moving on to the next column if a cell is blank) for one Lookup Value?

    1. Hi Mia,

      You can use nested IFERROR functions to do sequential Vlookups as shown in this example.

  25. Hey -- I tried this on excel 2016 and it isn't working because COUNTIF isn't returning an array - simply one value which doesn't correspond to an index in MATCH. Any ideas on why this is happening in my case?

  26. What is limitation for range?

    500 rows is ok

    1000 rows is NOT OK (shows doubles)

  27. I have a large spreadsheet. Serial numbers are in Column "A"; Warranty Expiration in Column "E". Serial numbers in Column A may have duplicates.
    For example; Serial Number 12345 may appear in cell A2 and A7.

    Column E may be blank (if no warranty exists); or may have two different dates (12/1/2015 in E2 and 12/1/2019 in E7 for example).

    I need the furthest out warranty expiration date from Column E per unique Serial Number (Col A) - basically consolidate duplicate serial numbers and return a unique warranty end date.

    Ultimately I would see Serial Number 12345 in A2 and 12/1/2019 in E2.

    How do I do that?

    1. Hello, Gina,

      I can suggest you to take a look at the following article about data consolidation in Excel. If we understand your task correctly, it may help you with your task.

      If it won't help, I'm afraid you will need some kind of a macro. Since we don't help with those, please ask around Mr. Excel forum for it.

      I really hope you'll manage to solve the task!

  28. I have a 19+ digit variant number always starting with 6................-... The "-" is always on number 19 slot after which a digit or two or three or four digits follows. These unique numbers are always exist once within column H to X in each row of data. Sometimes, i could have 60 thousand row from which to extract this value into one specific column. Definitely, l need formular help to achieve this task. Can you help me please with something that will do this and still give me the result as editable values?

  29. Please help!!!
    I want to extract the list(data validation) from the data as below. First lookup the PO# and then create a list of corresponding distinct values.

    PO# Category
    KIPS/IT/01 CPU
    KIPS/IT/01 LCD
    KIPS/IT/01 LCD
    KIPS/IT/02 Cable
    KIPS/IT/02 CPU
    KIPS/IT/02 LCD
    KIPS/IT/03 Connector
    KIPS/IT/04 CPU
    KIPS/IT/04 LCD
    KIPS/IT/04 Cable
    KIPS/IT/04 Connector
    KIPS/IT/04 Mouse
    KIPS/IT/05 CPU
    KIPS/IT/05 LCD
    KIPS/IT/05 Cable
    KIPS/IT/06 CPU
    KIPS/IT/06 LCD
    KIPS/IT/06 Cable
    KIPS/IT/06 Connector
    KIPS/IT/06 Mouse
    KIPS/IT/07 Webcam
    KIPS/IT/07 Toner
    KIPS/IT/07 Miscellaneous

  30. Hi,
    Is there a way out to extract/retrieve every nth value from a filtered data range?

    Thanks in advance :)

    1. Yes.it is possible.
      share some sample data to understand your query properly.

  31. Hey,Thanks for your help...
    I have a query on the same..I have been trying some expansion to this formula but no luck. I need to use this formula with couple of conditions, Such as date range from Jan to Mar or Apr to Jun or Jan to May, something like that..Appreciate your help.. thanks in advance

  32. Value of: Employee=500 & Relative=700

    How do I get respective value 500/700 in B1 when I write Employee/Relative in A1
    Please help.

  33. Dear Svetlana,

    I need to extract a corresponding value from say column i and j for a value from column b, and my 2nd number would be 'previous value' in column 'b' plus constant c and there corresponding value from columns i and j.

    b c d e f g
    6.950323 506.995 506.995 0.235604169 46.54370561 0.211560057
    57.50959672 0.187815384 56.3904946

    b+c
    7.149519 508.124 508.124 0.242356576 46.6473513 0.217010041 57.95264365 0.193082442 56.7702949

    this continues for entire data, with value of 'c' being constant getting added to value from column b, like equally spaced...

    Could you please help me out on this.

    With Best regards
    Rajesh KC

  34. Hello..

    i have data like below.
    sid dose date
    101 a 11-Jan-2017
    101 a 13-Jan-2017
    101 a 9-Jan-2017
    101 b 12-Jan-2017
    102 a 11-Jan-2017
    102 a 1-Jan-2017

    I want data like: I want unique subject, and unique treatment and minimum date in unique treatment.

    Can someone let me know how can u do that..

    Thank you
    Satheesh K

  35. I have a problem. I want to find and count duplicate values in two ranges. Suppose I hv two sheets called A & B, there are both similar & common values in both A:A range in A sheet & A:A range in B sheet. In both separate sheets A & B, if one common value matches/finds/exacts/duplicates then count otherwise dont. Anyone have some suggestions how to do it????

  36. I have a table that contains multiple values in column B for their corresponding dates in column A. For each date, i want to extract the values that appear only once and leave out the values that appear more than once. How do I do this please?

  37. Hi..
    Example
    My unique value is : 120450
    and in other sheet the unique value is with some other text for example: Rishabh 120450

    it is a huge list and in each line there is something other than Rishabh, but the unique value is there everytime with a space.
    I cant use Text to column to remove space as all the cell have different no of space.

    Pls suggest can we use Vlookup to find 120450 in the other sheet?

    Rishabh

  38. Dear Svetlana,
    I have a issue coming up with formula for my unique list of Issues (Issue)column and attached to it sub category (Issue Details). I have managed to come up with Unique list of Issue details but some of it fall for main Cat Issue twice. For example: Issue Detail "procedure breach" may fall in 2 types of Issues "Policy" and "communication". Is there any way that you could direct me to the formula that could deal with such a dependency ? Or give me a hint how this issue could be resolved ?

  39. Hi All,

    I need Unique (Distinct) count of project (only active & approved)
    By Month wise

    Example: Please find below scenario

    Project Status Date
    15746 active 1-Jan-16
    15780 active 20-Jan-16
    15795 active 5-Jan-16
    15822 active 21-Jan-16
    15822 active 22-Jan-16
    15822 Closed 2-Jan-16
    15780 Approve 2-Feb-16
    15822 active 22-Feb-16
    Answer: for Jan month:4 unique count(only active and approved Supplier)
    Can anyone help me out on this!!

    Thanks in advance
    Sri

  40. Hi Svetlana Cheusheva,
    i have a lot of data like this in one column and want to sort it for further working.
    113-00-00-00-0000-10121-5109-00000
    113-00-00-00-0000-10121-5110-00000
    113-00-00-00-0000-10121-5151-00000
    113-00-00-00-0000-10405-1114-00000
    113-00-00-00-0000-10437-1112-00000
    113-00-00-00-0000-10441-1112-00000
    i want to create a formula to select all cells in other sheet which have suppose "10121".
    Please help me to arrange my data.

  41. Thank you , =IFERROR(INDEX($A$2:$A$10, MATCH(0, INDEX(COUNTIF($B$1:B1, $A$2:$A$10), 0, 0), 0)), "") did work now for me.

  42. I have data

    001 - Xyz
    001 - ABC
    001 - DEF
    002 - MNO

    I want all the values of 001 in one cell. Please advise

  43. Hi All,

    I have a question. Will i be able to aggregate non numeric data based on one just one of the columns in excel. I want all aggregation at this level. I know this is possible if there are 2 columns through pivot. But i have 22 columns in my sheet. How do i aggregate based on just on of the columns ?

  44. When I try using your formulas (for distinct) I keep getting a ERROR:504 (using Open Office, and I have changed the commas to semi-colons). What am I missing? (Thank you in advance!)

  45. Hello,
    I am trying to create a list of names taken from a column which contains duplicate names within it.
    I want to create a separate table (so not effecting the data itself) which displays the most common values down to the most unique.
    For example:
    David
    Peter
    Paul
    Albert
    Jules
    Hector
    David
    Albert
    Hector
    Hector
    David
    David

    This would then display in a separate table/sheet as:
    David
    Hector
    Albert
    Paul
    Peter
    Jules

    Any help you can give would be invaluable.

    Kind Regards
    Thomas

    1. Hi Thomas,

      You can do it in this way:

      1. In the original table (Sheet1), count the number of name occurrences using this formula.

      2. In Sheet2 (or anywhere you want), extract the distinct names as described in this example.

      3. In Sheet2, replace the formulas that extract names with values using Paste Special (it's necessary because you will need to sort the list later, and Excel has problems with sorting 2 formula-driven columns).

      4. In Sheet2, enter a Vlookup formula to pull the occurrence numbers from the original table.

      5. Sort the distinct list by the occurrences column.

      I've created a small example for your reference and you can download it here. The source data is in Sheet1, the result on Sheet2.

  46. Hey,

    I did formula in one cell. After that if i drag down that formula will give incorrect detail. How to solve this? which keys i have to press?

  47. Fantastic...nicely done...thank you!

  48. Hi there,

    First, this is a wonderful site and I appreciate all your effort. I wonder how you can use Excel to:

    I have three columns all with 7 digit numbers. All three have overlapping values. I am trying to only find the values in column A that are not found in Column B or C.

    Find Unique Values in Column A not found in Column B or Column C?

    Any assistance would be greatly appreciated.

    Eric

  49. Hi Ms. Svetlana, I need help. I need to be identify data that comes with the wrong code.Please look at the data below
    Account Number AccountType Account Class
    1012929311 01 INDSAV
    1015619275 01 QUACOR
    1015658317 01 QUACOR
    1015680666 01 QUACOR
    1040135492 01 WISACC
    1040148603 02 WISACC
    All account class-WISACC is meant to have an Account Type of 01, how do identify the ones that come with O2 easily

    1. Hello Funmi,

      Is my understanding correct that a text string, say "1040135492 01 WISACC", is input in a single cell? If so, you can highlight wrong entries by creating a conditional formatting rule with this formula:

      =AND(NOT(ISERR(FIND("dress",A2))),ISERR(FIND("01 dress",A2)))

      Where A2 is the top-most cell with data.

      If the data is in 3 different columns, then create a rule with this formula:
      =AND($C2="WISACC", $B2<>1)

      Where B2 is Account Type and C2 is Account Class.

      The step-by-step instructions to create a conditional formatting rule can be found here: How to create a conditional formatting rule with a formula.

      1. HiThere

        Can I extend until 500 - $AF$6:$AF$500. Its looks like when I replace to 500 the formula cannot works'

        =IFERROR(INDEX($AF$6:$AF$16, MATCH(0, COUNTIF($AG$5:AG5,$AF$6:$AF$16) + (COUNTIF($AF$6:$AF$16, $AF$6:$AF$16)1), 0)), "")

  50. for unique value, you can use =IF(COUNTIF(F$2:'F2,F2)=1,F2,"")its working as well

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)