Unique values in excel columns

Filter for unique values or remove duplicate values

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

In Excel, there are several ways to filter for unique values—or remove duplicate values:

  • To filter for unique values, click Data > Sort & Filter > Advanced.
    The Sort & Filter group on the Data tab

  • To remove duplicate values, click Data > Data Tools > Remove Duplicates.
    Remove Duplicates

  • To highlight unique or duplicate values, use the Conditional Formatting command in the Style group on the Home tab.

Filtering for unique values and removing duplicate values are two similar tasks, since the objective is to present a list of unique values. There is a critical difference, however: When you filter for unique values, the duplicate values are only hidden temporarily. However, removing duplicate values means that you are permanently deleting duplicate values.

A duplicate value is one in which all values in at least one row are identical to all of the values in another row. A comparison of duplicate values depends on the what appears in the cell—not the underlying value stored in the cell. For example, if you have the same date value in different cells, one formatted as «3/8/2006» and the other as «Mar 8, 2006», the values are unique.

Check before removing duplicates: Before removing duplicate values, it’s a good idea to first try to filter on—or conditionally format on—unique values to confirm that you achieve the results you expect.

Follow these steps:

  1. Select the range of cells, or ensure that the active cell is in a table.

  2. Click Data > Advanced (in the Sort & Filter group).

    The Sort & Filter group on the Data tab

  3. In the Advanced Filter popup box, do one of the following:

To filter the range of cells or table in place:

  • Click Filter the list, in-place.

To copy the results of the filter to another location:

  • Click Copy to another location.

  • In the Copy to box, enter a cell reference.

  • Alternatively, click Collapse Dialog Button image to temporarily hide the popup window, select a cell on the worksheet, and then click Expand Button image .

  • Check the Unique records only, then click OK.

The unique values from the range will copy to the new location.

When you remove duplicate values, the only effect is on the values in the range of cells or table. Other values outside the range of cells or table will not change or move.  When duplicates are removed, the first occurrence of the value in the list is kept, but other identical values are deleted. 

Because you are permanently deleting data, it’s a good idea to copy the original range of cells or table to another worksheet or workbook before removing duplicate values.

Follow these steps:

  1. Select the range of cells, or ensure that the active cell is in a table.

  2. On the Data tab, click Remove Duplicates (in the Data Tools group).

    Remove Duplicates

  3. Do one or more of the following:

    • Under Columns, select one or more columns.

    • To quickly select all columns, click Select All.

    • To quickly clear all columns, click Unselect All.

      If the range of cells or table contains many columns and you want to only select a few columns, you may find it easier to click Unselect All, and then under Columns, select those columns.

      Note: Data will be removed from all columns, even if you don’t select all the columns at this step. For example, if you select Column1 and Column2, but not Column3, then the “key” used to find duplicates is the value of BOTH Column1 & Column2.  If a duplicate is found in those columns, then the entire row will be removed, including other columns in the table or range.

  4. Click OK, and a message will appear to indicate how many duplicate values were removed, or how many unique values remain. Click OK to dismiss this message.

  5. Undo the change by click Undo (or pressing Ctrl+Z on the keyboard).

Note: You cannot conditionally format fields in the Values area of a PivotTable report by unique or duplicate values.

Quick formatting

Follow these steps:

  1. Select one or more cells in a range, table, or PivotTable report.

  2. On the Home tab, in the Style group, click the small arrow for Conditional Formatting, and then click Highlight Cells Rules, and select Duplicate Values.
    Duplicate values

  3. Enter the values that you want to use, and then choose a format.

Advanced formatting

Follow these steps:

  1. Select one or more cells in a range, table, or PivotTable report.

  2. On the Home tab, in the Styles group, click the arrow for Conditional Formatting, and then click Manage Rules to display the Conditional Formatting Rules Manager popup window.
    Conditional Formatting menu with Manage Rules highlighted

  3. Do one of the following:

    • To add a conditional format, click New Rule to display the New Formatting Rule popup window.

    • To change a conditional format, begin by ensuring that the appropriate worksheet or table has been chosen in the Show formatting rules for list. If necessary, choose another range of cells by clicking Collapse Button image button in the Applies to popup window temporarily hide it. Choose a new range of cells on the worksheet, then expand the popup window again Button image . Select the rule, and then click Edit rule to display the Edit Formatting Rule popup window.

  4. Under Select a Rule Type, click Format only unique or duplicate values.

  5. In the Format all list of Edit the Rule Description, choose either unique or duplicate.

  6. Click Format to display the Format Cells popup window.

  7. Select the number, font, border, or fill format that you want to apply when the cell value satisfies the condition, and then click OK. You can choose more than one format. The formats that you select are displayed in the Preview panel.

In Excel for the web, you can remove duplicate values.

Remove duplicate values

When you remove duplicate values, the only effect is on the values in the range of cells or table. Other values outside the range of cells or table will not change or move. When duplicates are removed, the first occurrence of the value in the list is kept, but other identical values are deleted.

Important: You can always click Undo to get back your data after you have removed the duplicates. That being said, it’s a good idea to copy the original range of cells or table to another worksheet or workbook before removing duplicate values.

Follow these steps:

  1. Select the range of cells, or ensure that the active cell is in a table.

  2. On the Data tab, click Remove Duplicates .

  3. In the Remove Duplicates dialog box, unselect any columns where you don’t want to remove duplicate values.

    Note: Data will be removed from all columns, even if you don’t select all the columns at this step. For example, if you select Column1 and Column2, but not Column3, then the “key” used to find duplicates is the value of BOTH Column1 & Column2.  If a duplicate is found in Column1 and Column2, then the entire row will be removed, including data from Column3.

  4. Click OK, and a message will appear to indicate how many duplicate values were removed. Click OK to dismiss this message.

Note: If you want to get back your data, simply click Undo (or press Ctrl+Z on the keyboard).

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

See Also

Count unique values among duplicates

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

If I have a column with values, and I want to find out what distinct values are in there (not how many — but the actual distinct values), how can I do that?

In SQL Server I would do something like

SELECT Distinct(MyColumn) FROM MyTable

asked Oct 1, 2009 at 15:34

Kjensen's user avatar

KjensenKjensen

6,47417 gold badges43 silver badges53 bronze badges

2

Simpler than you might think:

  • Click the Data Ribbon Menu
  • Select the Advanced Button in the Sort & Filter section
  • Fill in the dialog Box, copying the results to another location and making sure you tick Unique records only

enter image description here

Community's user avatar

answered Oct 1, 2009 at 15:48

A Dwarf's user avatar

A DwarfA Dwarf

18.9k1 gold badge44 silver badges66 bronze badges

4

Excel 2007 and 2010:
Use the Remove Duplicates menu option under the Data header.

Excel 2003:
Easy way:

  1. Make sure your data has a header
  2. Data —> Filter —> Advanced Filter
  3. Check Unique Records Only
  4. Select Copy to another location
  5. Click OK

Hard way:

Write a macro with the following code:

'Remove duplicates from sorted list
Sub getDistinct()
    Do While ActiveCell.Value <> ""
        If ActiveCell.Value = ActiveCell.Offset(1, 0).Value Then
            ActiveCell.Select
            Selection.Delete Shift:=xlUp
        Else
            ActiveCell.Offset(1, 0).Activate
        End If
    Loop
End Sub

That gives you your distinct list. You may want to copy your list to another sheet first.

HK boy's user avatar

answered Oct 1, 2009 at 15:43

Nathan DeWitt's user avatar

Nathan DeWittNathan DeWitt

6,0879 gold badges35 silver badges41 bronze badges

0

Or (a simple crude way):

In B1,

=IF(COUNTIF(A$1:A1,A1)=1,A1,"") 

and copy down. It just copies the first occurrence of each value across (in the row that it occurs in).

slhck's user avatar

slhck

220k69 gold badges596 silver badges585 bronze badges

answered Aug 16, 2011 at 15:35

Tapgas's user avatar

TapgasTapgas

2713 silver badges2 bronze badges

1

I use two main methods to get distinct values — the first is the invaluable Remove Duplicates tool as suggested by Nathan DeWitt.

The downside to Remove Duplicates is that you lose data. Despite the power of Ctrl+z you may not wish to do this for various reasons — eg you may have filters currently selected that make it quite messy to remove duplicates to get your distinct list of values.

The other method, not mentioned above is to use a Pivot Table.

Let’s say this is your table and you want to get the distinct list of Platforms.
dummy table

Insert a Pivot Table with the table as your data source.

Now select the Platform(s) column as your Row Labels.

Voila! A list of distinct values.

pivot table as distinct value list

If you wish to tidy this up, you can switch off Field Headers and set Grand Totals to be Off for Rows and Columns.

Community's user avatar

answered Apr 4, 2013 at 9:38

Andi Mohr's user avatar

Andi MohrAndi Mohr

4,1704 gold badges31 silver badges46 bronze badges

0

Or you can include the filter option in a macro

    Columns("A:A").AdvancedFilter Action:=xlFilterInPlace, Unique:=True

answered Apr 13, 2011 at 9:37

cjcottell's user avatar

cjcottellcjcottell

611 silver badge1 bronze badge

For me, the most simple way to sort is to use «Filter» option.

First step is to find the duplicate values with Conditional Formatting -> Highlight Cells Rules -> Duplicate Values.

Then click the arrow on the Column you have the duplicates (in this case «Platforms») -> Filter by Color (Cells color or font color).

answered Mar 6, 2017 at 18:54

Just Me's user avatar

Just MeJust Me

77813 silver badges35 bronze badges

2

In Excel 365 we now have UNIQUE(), which returns an array of unique rows.

answered Mar 2, 2021 at 14:09

Tim Galvin's user avatar

1

Post Banner 2@2x.png

There are many scenarios you may come across while working in Excel where you only desire unique values in a list. You might want to rid your data of duplicates to create summaries, populate drop-down lists, or remove duplicates that found their way into your spreadsheet.

Luckily, Microsoft Excel offers many ways to accomplish summarizing values into a unique listing and depending on your particular situation, you may use different methods to accomplish the task at hand.

In this article, we’ll cover a bunch of different ways to identify those unique values so you have a full set of tactics to handle anything thrown your way. Let’s dive in!

1. Use The UNIQUE Function

With the release of Dynamic Array functions in 2020, Excel now offers a powerful function right out of the box to provide a simple way to pull together a list of unique values. Simply input the range you would like to analyze inside the UNIQUE Function and you’ll have the unique results delivered in a Spill Range below the formula.

Unique Function.png

If you’re looking for a more long-term solution, convert your data set into an Excel Table (ctrl + t) and point your UNIQUE function to read the table column. This will allow you to always have a more dynamic listing as your data grows or shrinks over time.

Unique function with table.png

Pro Tip: If you want your list in alphabetical order add the Sort Function to your formula:

=SORT(UNIQUE(Table1[State]))

2. Use An Array Formula

Before the UNIQUE function was released, Excel users were left using more complex methods to compile a list of unique values from a range. Pretty much all of these methods involved using array formulas (think Ctrl+Shift+Enter) to output the end result. The formula I will share in this post does not require keying in Ctrl+Shift+Enter to activate it, hence why I prefer it. The downside to using an Array formula over an Dynamic Array function is you have to carry it down manually, there is no Spill Range functionality that will automatically resize your list.

I won’t go into the details of how this formula works (if interested go here), just know if you set it up properly it will magically work. Make sure you pay close attention to your dollar signs at the beginning of the COUNTIF function. It does matter that the first cell reference stays static while the other one changes as you carry the formula down (ie $G$3:G3 in the below example).

Finally, after you setup the first formula, you’ll need to drag the formula down until you start seeing #N/As. You’ll want to monitor your list if your data will be changing in the future to ensure it is picking up all the unique results. As a rule, I always make note to ensure at least one #N/A is showing at the bottom of my list.

Lookup Formula.png

FORMULA: =LOOKUP(2,1/(COUNTIF($G$3:G3,$B$3:$B$12)=0),$B$3:$B$12)

3. Apply A Filter

If you would like to see a list of unique values without necessarily needing to store the list, you can utilize a cell Filter (ctrl + shift + L). Apply a filter to your data and click the filter arrow to see a list showing all the unique values within that particular column of data.

Filter.png

4. Pivot Table

A Pivot Table is another good way to list out unique values. Select your data range (ensuring every column has a unique header value) and go to Insert > Pivot Table. When the Insert Dialog box appears , simply hit the OK button and you can start pivoting your data.

Drag the name of the column you would like to see a unique list of value for into the “Rows” quadrant. You should instantly see your list populate within the Pivot Table.

5. Remove Duplicates

If you actually want to modify your data so it only has unique values, you can utilize Excel’s Remove Duplicate button. This feature can be used on a range of cells or within an Excel Table.

Remove Dups 1.png

Follow these steps to utilize this functionality:

  1. Select your range of data

  2. Navigate to the Data Ribbon tab.

  3. Click the Remove Duplicates button within the Data Tools button group

  4. Check the combination of columns you’d like to be unique

Remove Dups 2.png

6. Highlight Duplicates With Conditional Formatting

You may run into situations where you want to quickly visualize if there are any duplicates in your data set. This is where you can apply a little bit of conditional formatting and luckily there is a preset to flag duplicate values!

Highlight Dups 1.png

Just follow these simple steps:

  1. Highlight the cell range you want to analyze

  2. Navigate to the Conditional Formatting button on the Home tab

  3. Select Highlight Cells Rules

  4. Select Duplicate Values…

  5. Click OK

7. Use A Counting Formula

You might want to pursue utilizing a formula to flag your duplicate values. This can be done by using the COUNTIF() function. The below example shows how you can analyze each cell in the data range and understand if that value occurs more than once. If you have any count that is great than 1, you know there’s a duplicate within your data set.

Example Formula: =COUNTIF($D$4:$D$13, D4)

After you have implemented the formula, simply apply a filter and filter out all the “1” values.

Formula Dups.png

If you are more concerned with having a duplicate row across multiple columns, you can add a helper column (Column D in the below example) that joins the values of the columns you want to ensure are unique. After the helper column is created, point your COUNTIF function to it and repeat the steps in the prior example.

Formula Dups2.png

Any Others I Missed?

Whew, that was a lot of techniques we went through to get to pretty much the same result. Hopefully, you start to realize as you find yourself needing to pull together a list of unique values, how valuable knowing all the options available to you in Excel. I’m sure there were other great methods that I overlooked or haven’t discovered yet. Please let me know if you have any tips in the comments section and I can growth this article even further!

I Hope This Helped!

Hopefully, I was able to explain how you can use a variety of methods to create unique lists of your data. If you have any questions about this technique or suggestions on how to improve it, please let me know in the comments section below.

Chris Newman 2020 - TheSpreadsheetGuru

About The Author

Hey there! I’m Chris and I run TheSpreadsheetGuru website in my spare time. By day, I’m actually a finance professional who relies on Microsoft Excel quite heavily in the corporate world. I love taking the things I learn in the “real world” and sharing them with everyone here on this site so that you too can become a spreadsheet guru at your company.

Through my years in the corporate world, I’ve been able to pick up on opportunities to make working with Excel better and have built a variety of Excel add-ins, from inserting tickmark symbols to automating copy/pasting from Excel to PowerPoint. If you’d like to keep up to date with the latest Excel news and directly get emailed the most meaningful Excel tips I’ve learned over the years, you can sign up for my free newsletters. I hope I was able to provide you some value today and hope to see you back here soon! — Chris

Unique values are those that appear on a list just once.

When working with data in Excel, you will often come across datasets that have duplicates in the column and you will have to extract the unique values or items from that columns

In fact, it is one of the most common data cleaning tasks, as it helps remove duplicates, thereby saving memory space as well as processing time.

More importantly, by removing redundancy, it keeps the data organized and makes it easier to make inferences.

In this tutorial we will show you three ways to get unique values from a column in Excel:

  • Using the Remove Duplicates tool
  • Using the Advanced Filter tool
  • Using the UNIQUE function (Excel 365 and later versions)

We will demonstrate each of the above methods by applying them to the following list of names:

Names Dataset with repetition / duplicates

Notice that the name John Smith appears three times in the above list, and the name Manuel Braun appears twice. So our aim here would be to only extract the unique names from this list (no repetitions).

Let’s see some simple ways to do this in Excel.

Using the Excel Remove Duplicates Tool to Get Unique Values from a Column

Excel has an in-built tool to instantly remove all the duplicate values and give you only the unique ones.

This is the simplest, quickest and so far, the most commonly used method to get unique values from a column.

Here are the steps to get unique values from our sample Names list:

  1. Select the range of cells containing your list. In our example, select the range A2:A9
  2. Click on the Data tab.
  3. Click on the Remove Duplicates button (from the Data Tools group).
Click on Remove duplicates
  1. This opens the Remove Duplicates window.
  2. Check all the settings and click on OK.
Select the names column
  1. You should see a message box informing you about how many duplicate values were removed and how many unique values remain in your list.
Prompt to tell you how many duplicate values have been found
  1. Click OK.

You should now be left with a list of only unique values. 

List of unique names in the column

Note that the names John Smith and Manuel Braun now appear just once in the list. 

Note: The Remove Duplicates tool directly applies changes to the selected data cells by deleting all the duplicate values. In other words, it affects your original data. So if you want to retain the original list, it’s a good idea to make a copy of the list and then apply the Remove Duplicates tool to it.

Also read: How to Generate Random Names in Excel

Using the Excel Advanced Filter Tool to Get Unique Values from a Column

The next method is also quite commonly used in removing duplicates.

It basically involves using an Advanced Filter tool to remove duplicates and display the list of unique values either in-place or in a new location.

Here are the steps to use the Advanced Filter to get unique values:

  1. Select the range of cells containing your list. In our example, select the range A1:A9. Make sure you select the column header along with the data.
  2. Click on the Data tab.
  3. Click on the Advanced button (from the Sort & Filter group).
Click on the Advanced option
  1. This opens the Advanced Filter dialog box.
Advanced Filter dialog box
  1. If you want to remove duplicates from the original list, then check the radio button next to ‘Filter the list, in-place’. If you want to retain the original list and display the unique values in a new range of cells, then check the radio button next to ‘Copy to another location’. In this case, you will need to enter in the field next to ‘Copy to’ the reference to the first cell where you want the filtered list to appear. In our case, we specified the cell reference $B$1.
Select Copy to another location
  1. Make sure that the box next to ‘Unique records only’ is checked.
Select Unique records only
  1. Click OK.

You should now see the list of only unique values from your original list in the cell location that you had specified.

All duplicate values have been removed
Also read: How to Count Unique Values in Excel (5 Formulas Methods)

Using the UNIQUE Function to get Unique Values from a Column (Excel 365)

The UNIQUE function has been added to the Excel functions arsenal, just recently.

So, you can use this method only on Excel 365 (at this point in time).

The UNIQUE function simply takes a range of cells (or an array) and returns a list of unique values from this list. It also gives you the option to return just the unique values from the list or the list of distinct unique values. 

It’s a dynamic function, so it returns an array of values that ‘spill’ onto neighboring cells.

The syntax for the UNIQUE function is as follows:

UNIQUE (array, [by_col], [exactly_once])

Here,

  • array is the array or range of cells from which you want to get the unique values
  • by_col is a TRUE/FALSE or 0/1 value that specifies whether the function should extract unique values by rows or columns. By default, the value is FALSE (which means it extracts by row).
  • exactly_once specifies if you want to extract values that are distinct and unique values or just unique. A value of FALSE (the default value) means that you want the list of values that appear at least once. A value of TRUE means that you want to remove all values that appear more than once (retaining only the values that don’t repeat).

Let us see how we can apply this function to get the unique values from our sample dataset:

  1. Click on an empty cell in a new column (Make sure the column is empty, allowing space for the resulting array to spillover). In our example, we select cell B2.
  2. Insert the following formula in the cell: =UNIQUE(A2: A9)
  3. Press the return key.

You should now see only the unique values from the selected range displayed in column B.

Unique Function in Excel 365

If you want to display only the values that appear exactly once in the list, then you can specify the third parameter is TRUE, as shown below:

=UNIQUE(A2:A9,,TRUE)

Here’s the result that you will get in this case:

Unique values that only appear once

Unlike the first two methods, the result of the UNIQUE formula is dynamic. This means that in case your original data changes, then the result of the UNIQUE function will automatically update.

In this tutorial, we showed you 3 ways to get unique values from a column in Excel.

The first method uses the simple ‘Remove Duplicates’ tool which applies changes to the original range of cells. 

The second method uses the Advanced Filter, which lets you choose if you want to apply the tool to the original values or to a copy of the original values. 

The third method uses the dynamic UNIQUE function, which is quite flexible and easy to use but is only available in Excel 365 at this time.

We hope this tutorial was helpful for you.

Other articles you may also like:

  • How to Remove Duplicate Rows based on one Column in Excel?
  • 3 Easy Ways to Duplicate Sheet in Excel (Shortcuts + VBA)
  • How to Find Duplicates in Excel (Conditional Formatting/ Count If/ Filter)
  • How to Generate Random Numbers in Excel (Without Duplicates)
  • How to Enter Sequential Numbers in Excel?
  • How to Flip Data in Excel (Columns, Rows, Tables)?

Author: Oscar Cronquist Article last updated on February 22, 2023

Picture describing unique distinct values and unique values

First, let me explain the difference between unique values and unique distinct values, it is important you know the difference so you can find the information you are looking for on this web page.

The picture above shows a list of values in column B, note value AA has a duplicate. Unique distinct values are all cell values but duplicate values are merged into one distinct value. In other words, duplicates are removed only one instance of each value is left in the list.

Column F contains unique values from column B, meaning values that exist only once in column B. Value AA is not in column F because it has a duplicate, in other words, AA is not unique in column B. To filter duplicates, read this post: Extract a list of duplicates from a column

Table of Contents

Working with unique distinct values

  1. How to extract unique distinct values from a column [Formula]
    1. Video
    2. Copy unique distinct values
    3. Explaining formula
    4. Get Excel file
  2. Extract unique distinct values (case sensitive) [Formula]
    1. Video
    2. Explaining formula
    3. Get Excel file
  3. Filter unique distinct values [Advanced Filter]
    1. Video
    2. Copy unique distinct values to another location
    3. Filter unique distinct values, in place
  4. Highlight unique distinct values [Conditional Formatting]
    1. Video
    2. Explaining formula
    3. Sort Conditional formatted cells at the top
  5. How to hide duplicate values [Conditional Formatting]
  6. Put unique distinct values at the top of the list [Conditional Formatting]
  7. Extract unique distinct sorted values from a cell range [UDF]
    1. Video
    2. How to create an array formula
    3. VBA code
    4. Where to put the code?
  8. Filter unique distinct values from multiple sheets [Add-In]
    1. Video
  9. How to extract unique distinct values from a column [Old array Formula]
    1. How to create an array formula
    2. Explaining formulaExtract unique distinct values — Pivot Table (Link)

      Working with unique values

  10. How to filter unique values from a list [Formula]
    1. Explaining formula
    2. Get Excel file
  11. Highlight unique values [Conditional Formatting]
    1. Video
    2. Sort unique values at the top
  12. Useful tips
    1. Excel defined tables
    2. Named ranges
  13. Remove errors, Excel version 2007 and later
  14. Remove errors, Excel version 2003 and earlier
  15. How to ignore blank cells
    1. Video
    2. Get Excel file
  • What you will learn in this article
  • What is possible with formulas?
  • What is the easiest way to filter unique distinct values?

What you will learn in this article

  • The difference between unique distinct values and unique values.
  • How to decide which Excel feature to use.
  • How to use a formula that extracts unique distinct values.
    • How to copy the values returned by the formula.
    • How the formula works and the functions being used.
  • How to filter unique distinct values considering lowercase and uppercase letters.
  • How to filter unique distinct values using the Advanced Filter.
  • How to highlight unique distinct values using Conditional Formatting.
  • How to build a User defined Function that filters unique distinct values sorted from A to Z.
    • Where to put the VBA code.
    • How to enter and use the User defined Function.
  • How to filter unique values using a formula.
  • How to highlight unique values using Conditional Formatting.

Back to top

What is possible with formulas?

You have quite a few options to choose from if you are looking for a way to create a unique distinct list in your workbook, all demonstrated in this post or on this website. Not only an exceptionally small regular formula, if you want to use that, but also awesome built-in features in Excel that makes your work so much easier.

Formulas are very versatile, they allow you to build solutions for very specific tasks like filtering unique distinct values from two separate columns or three. If your list contains blanks then this article is for you: Extract a unique distinct list and remove blanks

Perhaps you want to do a wildcard lookup and return unique distinct values or simply return unique distinct values based on a condition.

I have also written articles that explains how to create a unique distinct list sorted alphabetically, sum or frequency.

There is also a formula for extracting unique distinct values located in a multi-column cell range, it is a somewhat more complicated array formula, however, there is a custom function as well, if you prefer that.

Back to top

What is the easiest way to filter unique distinct values?

I would choose the advanced filter if you are not looking for a formula. It lets you quickly filter a unique distinct list.

If you know that you will be extracting unique distinct values from time to time, like in a dashboard or an interactive worksheet, I recommend using a formula and an Excel defined table. You won’t need to repeat the same steps over and over compared to the advanced filter and that will save you time and repetitive work.

However working with a large data set may slow down the formula calculations considerably depending on your computer hardware, so perhaps the User Defined Function [UDF] is a better choice or even better a pivot table, if you have huge amounts of data to work with.

The Excel Pivot table is lightning fast even with huge data tables but it does have a little learning curve and it requires a few steps to set it up but in my opinion, it is totally worth learning how to use pivot tables. You will be surprised how easy it is to start working with Excel Pivot tables.

Conditional Formatting allows you to format cells determined by a built-in rule or a formula you construct. In this post, you will find a Conditional Formatting formula that highlights unique and unique distinct values. Did you know that you can easily sort highlighted values on top? Check out conditional formatting.

I have made an add-in that lets you extract unique, unique distinct and duplicate values and records from multiple worksheets. This allows you to easily bring together data from multiple sources in your workbook.

There is also a useful array formula in this article that extracts a case-sensitive unique distinct list, this is a special case which the built-in Excel tools can’t accomplish.

Back to top

1. Create a list of unique distinct values

Picture of a unique distinct list

Column B contains names, some cells have duplicate values.  A formula in column D extracts a unique distinct list from column B.

Update: 2017-08-15!

This formula is even smaller than the array formula and you are not required to enter this as an array formula. The following formula is for older Excel versions than Excel 365 subscribers.

Formula in cell D3:

=LOOKUP(2,1/(COUNTIF($D$2:D2,$B$3:$B$21)=0),$B$3:$B$21)

I will explain how this formula works in the video below and in section 1.3 also below.

Back to top

Update: 2020-05-28!

Microsoft Excel released new functions for Excel 365 subscribers in January 2020. One of those new functions is the UNIQUE function, it allows you to easily extract a unique distinct list using only one function.

Formula in cell D3:

=UNIQUE(B3:B21)

This formula is entered as a regular formula, however, it is a dynamic array formula. Microsoft Excel introduced dynamic array formulas in January 2020 as well.

Dynamic array formulas expand to cells below automatically if more than one value is returned from the formula. Microsoft Excel calls this behavior spilling. You can find more example of the UNIQUE function here.

I will describe a formula for older Excel versions below.

Extract unique distinct values — Excel 365 (Link)
Extract unique distinct values sorted from A to Z — Excel 365 (Link)
Extract unique distinct values ignoring blanks — Excel 365 (Link)
Extract unique distinct values sorted from A to Z ignoring blanks — Excel 365 (Link)

1.1 Video

This video demonstrates how to use the formula:

Subscribe to Get Digital Help on Youtube:

Back to top

1.2 Copy unique distinct values

To copy unique distinct values to another location you must make sure you copy the values and not the formula:

  1. Select list
  2. Copy list, shortcut keys: CTRL + C or press this button:
  3. Press with right mouse button on on destination cell and press with left mouse button on the black arrow next to «Paste Special…»
    How to copy unique distinct values returned from a formula
  4. Then press with left mouse button on «Paste Values» button.

Back to top

1.3 Explaining formula in cell D3

Step 1 — Count previous values above the current cell

The COUNTIF function allows you to count values based on a condition. With the help from an expanding cell reference, the formula knows which of the values that have been extracted.

In cell D3 no values have been extracted so it compares the value in the cell above current cell, this happens to be the Header value. Make sure you don’t have a value in the list that matches the header value, it won’t be extracted.

COUNTIF($D$2:D2,$B$3:$B$21) is entered in column F, displayed in the picture below.

Picture of a COUNTIF function array that is a part of a unique distinct formula.

The value in cell D2 is not found in any instance in cell range B3:B21, all values in the array are 0 (zero). Note that the array has the same size as the list in column B, 19 values.

Step 2 — Compare array with 0 (zero)

To identify values that have not been shown the formula compares the array with 0 (zero) and the result are boolean values (TRUE or FALSE) for each value in the array.

COUNTIF($D$2:D2,$B$3:$B$21) = 0

Image of a logical expression returning TRUE or FALSE

The array contains 19 boolean values, all TRUE.

Step 3 — Divide 1 with array

The boolean value TRUE is equal to 1 and FALSE is equal to 0. If a value in the array is TRUE the result will be 1 because 1/TRUE equals 1.

If a value in the array is FALSE the result will be #DIV0! because 1/FALSE is 1/0 and you can’t divide a number with zero. Excel returns an error.

Picture of an array that extracts unique distinct values

The good thing about the LOOKUP function is that it ignores errors, see next step.

Step 4 — LOOKUP value

The LOOKUP function is designed to work with sorted cell ranges or arrays, you get weird results if they are not sorted. Be careful using the LOOKUP function.

However, in this case, the values in the array are either 1 or #DIV0!. Surprisingly it ignores errors, the only thing it can find then is a value that is 1.

The first argument in the LOOKUP function is 2 so the function finds the last largest value that is equal to 2 or smaller.

LOOKUP(2,1/(COUNTIF($D$2:D2,$B$3:$B$21)=0),$B$3:$B$21)

becomes

LOOKUP(2,{1;1;1;1;1;1;1;1;1; 1;1;1;1;1;1;1;1;1;1},$B$3:$B$21) and matches the last value in the array. LOOKUP function then returns the corresponding value in cell range $B$3:$B$21 which is Almagro, Nicolas

Back to top

1.4 Excel file

Extract a unique distinct list sorted from A to Z
Extract a unique distinct list sorted from A to Z ignore blanks
Vlookup – Return multiple unique distinct values
Unique distinct list sorted alphabetically based on a condition
Extract a unique distinct list from two columns
Extract a unique distinct list from three columns
Filter unique distinct records

Back to top

2. Extract a unique distinct list (case sensitive)

Picture of a case sensitive unique distinct list extracted by a formula

The following array formula lists unique distinct values from a list also considering upper and lower letters. For example, the value «Aa» is not equal to «AA».

Array formula in cell D3:

=INDEX($B$3:$B$15, MATCH(0, FREQUENCY(IF(EXACT($B$3:$B$15, TRANSPOSE($D$2:D2)), MATCH(ROW($B$3:$B$15), ROW($B$3:$B$15)), «»), MATCH(ROW($B$3:$B$15), ROW($B$3:$B$15))), 0))

Excel 365 subscribers can use this regular somewhat shorter formula in cell D3 than the formula below:

=LET(z, B3:B15, x, SEQUENCE(z), INDEX(z, MATCH(0, FREQUENCY(IF(EXACT(z, TRANSPOSE($D$2:D2)), x, «»), x), 0))

The formula above contains two new formulas: LET function and the SEQUENCE function.

This article explains the formula: Extract a case sensitive unique list from a column — Excel 365

2.1 Video

This video demonstrates how to build a formula that extracts a case-sensitive unique distinct list:

Subscribe to Get Digital Help on Youtube:

This post shows you how to extract a case sensitive unique list from a column:

Recommended articles

test

How to enter an array formula

Back to top

2.2 Explaining the array formula in cell C3

Step 1 — Transpose previous values

TRANSPOSE($D$2:D2)

becomes

TRANSPOSE({«Unique distinct list (case sensitive)»;»Aa»})

and returns

{«Unique distinct list (case sensitive)»,»Aa»}

Note that the ; (semicolon) changes to a , (comma)

Recommended reading:

Recommended articles

Step 2 — Check if two text strings are exactly the same, also case sensitive 

EXACT($B$3:$B$15, TRANSPOSE($D$2:D2))

becomes

EXACT($B$3:$B$15, TRANSPOSE({«Unique distinct list (case sensitive)»,»Aa»})

becomes

EXACT($B$3:$B$15, TRANSPOSE({«Unique distinct list (case sensitive)»,»Aa»})

becomes

EXACT({«Aa»; «CC»; «AA»; «BB»; «BB»; «EE»; «bb»; «Aa»; «aa»}, TRANSPOSE({«Unique distinct list (case sensitive)»,»Aa»})

and returns

{FALSE, TRUE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, TRUE; FALSE, FALSE}

Step 3 — Return relative position in array if TRUE

IF(EXACT($B$3:$B$15, TRANSPOSE($C$1:C1)), MATCH(ROW($B$3:$B$15), ROW($B$3:$B$15))

becomes

IF({FALSE, TRUE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, TRUE; FALSE, FALSE}, MATCH(ROW($A$1:$A$9), ROW($A$1:$A$9)))

becomes

IF({FALSE, TRUE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, FALSE; FALSE, TRUE; FALSE, FALSE}, {1;2;3;4;5;6;7;8;9})

and returns

{FALSE,1; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,8; FALSE,FALSE}

Recommended article:

Recommended articles

test

Step 4 — Calculate how often values exist in an array

FREQUENCY(IF(EXACT($B$3:$B$15, TRANSPOSE($C$1:C1)), MATCH(ROW($B$3:$B$15), ROW($B$3:$B$15)), «»), MATCH(ROW($B$3:$B$15), ROW($B$3:$B$15)))

becomes

FREQUENCY({FALSE,1; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,8; FALSE,FALSE},MATCH(ROW($B$3:$B$15),ROW($B$3:$B$15)))

becomes

FREQUENCY({FALSE,1; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,FALSE; FALSE,8; FALSE,FALSE},{1;2;3;4;5;6;7;8;9})

and returns

{1;0;0;0;0;0;0;1;0;0} Aa is found in position 1 and 8 in cell range $B$3:$B$15

Recommended articles

Step 5 — Find first empty value (0) in array

MATCH(0, FREQUENCY(IF(EXACT($B$3:$B$15, TRANSPOSE($C$1:C1)), MATCH(ROW($B$3:$B$15), ROW($B$3:$B$15)), «»), MATCH(ROW($B$3:$B$15), ROW($B$3:$B$15))), 0)

becomes

MATCH(0, {1;0;0;0;0;0;0;1;0;0}, 0)

and returns 2.

Recommended articles

test

Step 6 — Return value from position 2

INDEX($B$3:$B$15, MATCH(0, FREQUENCY(IF(EXACT($B$3:$B$15, TRANSPOSE($C$1:C1)), MATCH(ROW($B$3:$B$15), ROW($B$3:$B$15)), «»), MATCH(ROW($B$3:$B$15), ROW($B$3:$B$15))), 0))

becomes

INDEX($B$3:$B$15, 2)

and returns «CC» in cell C3.

Recommended articles

test

Back to top

2.3 Excel file

Back to top

Recommended articles

Case sensitive lookup and return multiple values
Filter values based on a condition — case sensitive (Excel 365)
Filter unique distinct values (case sensitive) [UDF]
Filter unique distinct records (case sensitive) [UDF]

Back to top

3. Extract unique distinct values [Advanced Filter]

First a little reminder, unique distinct values are all cell values but duplicate values are merged into one distinct value.

Picture explaining unique distinct values

3.1 Video

The following video shows you how to filter unique distinct values using Advanced Filter:

Subscribe to Get Digital Help on Youtube:

Back to top

3.2 Instructions — Copy unique distinct values to another location

Extract a unique distinct list advanced filter

This section describes how to extract unique distinct values using the built-in feature «Advanced Filter».

  1. Go to tab «Data» on the ribbon.
  2. Press the «Advanced Filter» button on the ribbon.

    Picture of tab data on the ribbon advanced filter button highlighted

  3. Press button «Copy to another location».

    Picture showing the Advanced Filter dialog box

  4. Press «List range:» and select range to filter unique distinct values.
  5. Press «Copy to: and select a range.
  6. Press «Unique records only» button to select it.
  7. Press with left mouse button on «OK» button to apply settings and start extracting.

Picture of extracted unique distinct values using advanced filter

Back to top

3.3 Instructions — Filter unique distinct values, in place

If you choose to filter unique distinct values in-place, press with left mouse button on the first option button in the dialog box.

Picture of unique distinct values filtered in-place using the Advanced Filter

You can then select unique distinct values and paste to another location, duplicate values are hidden and are ignored when you copy cell range B3:21 and paste to a new location, very useful.

Picture of filtered values using the Advanced Filter

The picture below shows you the selected distinct values after I cleared the Advanced Filter, duplicate values are not selected because they were hidden.

Picture of selected values using the advanced filter

Recommended articles

Lookup and return multiple values [Advanced Filter]
Extract all rows that meet critera in one column [Advanced Filter] 

An Advanced Filter is not the only powerful built-in feature in Excel, I highly recommend that you learn pivot tables. Perhaps the most powerful tool but also the least known:

Recommended articles

test

The Excel defined table is also extremely useful, it allows you to quickly sort, filter and manipulate data. Learn that and much more:

Recommended articles

test

How to use Excel Tables
An Excel table allows you to easily sort, filter and sum values in a data set where values are related.

Back to top

4. Highlight unique distinct values [Conditional Formatting]

Picture of highlighted unique distinct values using conditional formatting

This section demonstrates how to highlight unique distinct values using Excel’s built-in feature «Conditional Formatting».

The image shows you unique distinct values highlighted using Conditional Formatting.

4.1 Video

This video demonstrates how to highlight unique distinct values:

Subscribe to Get Digital Help on Youtube:

How to highlight unique distinct values

  1. Select cell range B3:B21.
  2. Go to tab «Home» on the ribbon.
  3. Press on «Conditional Formatting» button.
    Picture of conditional formatting button on the ribbon
  4. Press on «New Rule…».
    Picture of Conditional formatting dialog box
  5. Press on «Use a formula to determine which cells to format:».
  6. Type this formula: =COUNTIF($B$3:B3,B3)=1
  7. Press on «Format…» button.
  8. Pick a color.
  9. Press OK button.
  10. Press OK button again.

Back to top

4.2 Explaining Conditional Formatting formula

Highlight a unique distinct list Conditional formatting

A CF formula works somewhat differently than a regular formula, however, they may be harder to spot.

It is possible that you can’t even see if a cell range has CF applied to it or not, if no cells are highlighted.

I recommend that you copy the CF formula and enter it to an adjacent column to better show how they work.

Step 1 — COUNTIF function

The COUNTIF function has two arguments, the first argument is the cell range you want to count a specific value in. The second argument is the value you want to count.

COUNTIF(rangecriteria)

Step 2 — COUNTIF arguments

The first argument uses both relative and absolute cell references, $B$3:B3. The absolute part has dollar signs $B$3 meaning it does not change when the Conditional Formatting formula is applied to the next cell.

The relative part B3 does change when the Conditional Formatting formula is applied to the next cell.

COUNTIF($B$3:B3, B3)

Step 3 — Demonstrate calculations in cells B3 and B4

In cell B3 the function is COUNTIF($B$3:B3,B3)

and in cell B4: COUNTIF($B$3:B4,B4) and so on.

This technique using growing cell references lets you highlight the first instance of a value but not duplicate values.

Step 4 — Compare output to 1

How do we know if the value is a unique distinct value? Compare COUNTIF($B$3:B3,B3) to 1 and it will return TRUE or FALSE, like this:

COUNTIF($B$3:B3,B3)=1

The equal sign is a logical operator that returns TRUE or FALSE. Note, the comparison is not case sensitive. The output is a boolean value TRUE or FALSE.

COUNTIF($B$3:B3,B3)=1

becomes

1=1

and returns boolean value TRUE. Cell B3 is highlighted.

If COUNTIF($B$3:B3,B3) returns a number larger than 1 meaning there is at least a duplicate value in the cell range specified in the first argument. That prevents the Conditional Formatting formula from highlighting the cell.

Recommended articles
Highlight unique/duplicates
Highlight current date
Highlight lookup values
Highlight cells equal to

4.3 Sort Conditional formatted cells at the top

Tip! Press with right mouse button on on a highlighted cell, press with left mouse button on Sort and then on «Put Selected Cell Color On top» to arrange unique distinct values at the very top of your list.

Picture of press with right mouse button on menu showing how to sort highlighted cells on top

The picture below shows you all unique distinct values sorted together.

Picture of highlighted cells sorted on top of list

Back to top

5. Hide duplicate values [Conditional Formatting]

The image above demonstrates Conditional Formatting applied to a list of values, it changes the font color to white for duplicate values making them invisible or they appear hidden.

Keep in mind that the text is still there so if you copy the range and paste the values to a new range the hidden values are visible again. I recommend that you sort the visible values at the top in order to copy them correctly, instructions below.

Conditional Formatting formula:

=COUNTIF($B$3, B3)>1

Back to top

How to apply conditional formatting formula to cell range B3:B21

  1. Select cell range B3:B21.
  2. Go to tab «Home» on the ribbon.
  3. Press with left mouse button on the «Conditional Formatting» button.
  4. Press with left mouse button on «New Rule…»
  5. Press with left mouse button on «Use a formula to determine which cells to format:».
  6. Type the Conditional Formatting formula in «Format values where this is true:».
  7. Press with left mouse button on «Format…» button.
  8. Go to tab «Font» on the menu, see image above.
  9. Press with left mouse button on color drop-down list.
  10. Pick white.
  11. Press with left mouse button on OK button.
  12. Press with left mouse button on OK button.
  13. Press with left mouse button on OK button.

Back to top

6. How to sort unique distinct values at the top of the list

  1. Press with right mouse button on on one of the visible values in the list.
  2. Press with left mouse button on «Filter»
  3. Press with left mouse button on «Filter by Selected Cell’s Font color.

Recommended articles
Highlight unique values and unique distinct values in a multi-column cell range
Highlight unique distinct records
Highlight unique values in a filtered excel table
How to highlight duplicate values in a column
Check out the Conditional formatting category

Back to top

7. Extract unique distinct sorted values from a cell range [UDF]

Picture of unique distinct values sorted alphabetically using a user defined function

This UDF lets you create and sort a unique distinct list. First you need to copy the VBA code to your workbook, instructions below. Second, select a cell range. Third, type FilterUniqueSort(cell_ref) in the formula bar. Last, enter formula as an array formula, instructions below.

There is also a workbook for you to get.

Array formula in cell B2:B8212:

=FilterUniqueSort($A$2:$A$8212)

7.1 Video

This video explains how to implement and use the User Defined Function

Subscribe to Get Digital Help on Youtube:

7.2 How to create an array formula

  1. Type B2:B8212 in name box
  2. Type above array formula in formula bar
    Picture of the Excel name box and formula bar
  3. Press and hold Ctrl + Shift
  4. Press Enter once
  5. Release all keys

Recommended reading

Recommended articles

test

Back to top

7.3 VBA code

I am using the selection sort function to sort values. You can read more about the function here:

Using a Visual Basic Macro to Sort Arrays in Microsoft Excel

'Name User Defined Function and define paremeter
Function FilterUniqueSort(rng As Range)

'Dimension variables and declare data types
Dim ucoll As New Collection, Value As Variant, temp() As Variant
Dim iRows As Single, i As Single

'Redimension array variable
ReDim temp(0)

'Enable error handling
On Error Resume Next

'Iterate through each value in range
For Each Value In rng

'Check if number of characters in value is greater than 0 (zero), if true add value to collection ucoll
If Len(Value) > 0 Then ucoll.Add Value, CStr(Value)

'Continue with next value
Next Value

'Disable error handling
On Error GoTo 0

'Iterate through each value in collection ucoll
For Each Value In ucoll

'Save value to last container in array variable temp
temp(UBound(temp)) = Value

'Add new container to array variable temp
ReDim Preserve temp(UBound(temp) + 1)

'Next value
Next Value

'Remove last container in array variable temp
ReDim Preserve temp(UBound(temp) - 1)

'Save selected rows on worksheet to variable iRows
iRows = Range(Application.Caller.Address).Rows.Count

'Start User Defined Function SelectionSort with values in array variable temp
SelectionSort temp

'Add blanks to array variable temp to prevent error values on worksheet
For i = UBound(temp) To iRows

'Add container
ReDim Preserve temp(UBound(temp) + 1)

'Save blank to container
temp(UBound(temp)) = ""

'Continue with next value
Next i

'Transpose values in array variable temp and return those values to worksheet
FilterUniqueSort = Application.Transpose(temp)

End Function
'Name User Defined Function (UDF) and define parameters
Function SelectionSort(TempArray As Variant)
'This UDF sorts values in an array
'https://www.get-digital-help.com/how-to-extract-a-unique-list-and-the-duplicates-in-excel-from-one-column/#7.3

          'Dimension variables and declare data types
          Dim MaxVal As Variant
          Dim MaxIndex As Integer
          Dim i As Integer, j As Integer
          
          'Iterate through each value in array variable temp starting from last to first
          For i = UBound(TempArray) To 0 Step -1

              'Save value to variable MaxVal
              MaxVal = TempArray(i)

              'Save value stored in variable i to variable MaxIndex
              MaxIndex = i

              'Iterate through each value in array variable temp
              For j = 0 To i

                  'Check if value in array variable TempArray is larger than value stored in variable MaxVal
                  'Excel can compare text values as well, this action checks if a text value is before or after another value in a sorted list 
                  If TempArray(j) > MaxVal Then

                      'If true save value to variable MaxVal
                      MaxVal = TempArray(j)

                      'Save position to MaxIndex
                      MaxIndex = j
                  End If

              'Continue with next value
              Next j

              'Check if number stored in variable MaxIndex is smaller than number stored in variable i
              If MaxIndex < i Then

                  'Save value in array variable TempArray position i to array variable TempArray container position MaxIndex
                  TempArray(MaxIndex) = TempArray(i)

                  'Save value in variable MaxVal to array variable TempArray container position i
                  TempArray(i) = MaxVal
              End If
          Next i

      End Function

Back to top

7.4 Where to copy VBA code?

  1. Press Alt + F11 to open VB Editor
  2. Press with left mouse button on «Insert» on the menu
  3. Press with left mouse button on «Module» to create a module
  4. Copy (Ctrl + c) above VBA code and paste (Ctrl +v)  to the code module

Picture of VB Editor describing how to insert a module and where to paste the vba code

Back to top

More powerful User Defined Functions

Recommended articles

test

Recommended articles

test

Recommended articles

test

Back to top

8. Filter unique distinct values from multiple sheets add-in

Filter unique distinct values is an add-in for Excel 2007/2010/2013 that lets you extract

  • unique distinct values
  • duplicate values
  • unique distinct records
  • duplicate records

from multiple sheets. The Add-In contains 4 user-defined functions.

If a value in one of the ranges changes the function will automatically and instantly update the list.

Features

  • All user-defined functions remove blank values and blank records.
  • No error values when all values are extracted.
  • Filter values or records from up to 255 different cell ranges or sheets.

8.1 Watch this video where I demonstrate the Excel Add-In

Subscribe to Get Digital Help on Youtube:

What are unique distinct values?

Picture of defintion of unique distinct values

What are unique distinct records?

Picture of unique distinct records

Purchase Filter Unique Distinct Values From Multiple Sheets Add-in For Excel 2007/2010/2013 — Price $19 USD

Questions

Is there a money back guarantee?
Sure, you have a unconditional money back guarantee for 14 days.

Back to top

9. Create a list of unique distinct values [Old array Formula]

I recommend using the regular formula above since it is smaller and has an advantage of not being an array formula.

Picture of unique distinct values extracted using an array formula

Array formula in cell D3:

=INDEX($B$3:$B$21, MATCH(0, COUNTIF($D$2:D2, $B$3:$B$21), 0))

Thanks to Eero, who contributed the original array formula!

Back to top

The formulas above has an issue with blank cells, it returns a 0 (zero) in your list. This article shows you how to ignore blanks:

Recommended articles

test

9.1 How to create an array formula

You don’t need to follow these steps if you chose the regular formula.

  1. Copy the array formula above (Ctrl + c)
  2. Double press with left mouse button on cell B2
  3. Paste (Ctrl + v)
  4. Press and hold Ctrl + Shift simultaneously
  5. Press Enter
  6. Release all keys

If you made the above steps correctly the formula now has a beginning and ending curly bracket, like this:
{=INDEX($B$3:$B$21, MATCH(0, $D$2:D2, $B$3:$B$21), 0))}

Don’t enter these characters yourself, they appear automatically.

Copy cell B2 and paste to cells below as far as needed.

Back to top

9.2 How the array formula in cell B2 works

Step 1 — Create an array with the same size as the list

The COUNTIF function calculates the number of cells equal to a condition.

COUNTIF(rangecriteria)

COUNTIF($B$1:B1, $A$2:$A$20)

becomes

COUNTIF(«Unique distinct list»,{Federer,Roger; Djokovic,Novak; Murray,Andy; Davydenko,Nikolay; Roddick,Andy; DelPotro,JuanMartin; Federer,Roger; Davydenko,Nikolay; Verdasco,Fernando; Gonzalez,Fernando; Wawrinka,Stanislas; Gonzalez,Fernando; Blake,James; Nalbandian,David; Robredo,Tommy; Wawrinka,Stanislas; Cilic,Marin; Stepanek,Radek; Almagro,Nicolas} )

and returns:

{0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0}

This means the cell value in $B$1:B1 can’t be found in any of the cells in cell range $A$2:$A$20. If it had been found, somewhere in the array the number 1 would exist.

Step 2 — Return the position  of an item that matches 0 (zero)

The MATCH function returns the relative position of an item in an array that matches a specified value.

MATCH(lookup_value, lookup_array, [match_type]

MATCH(0, COUNTIF($B$1:B1, $A$2:$A$20), 0)

becomes

MATCH(0,{0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0},0)

and returns 1.

Step 3 — Return a cell value

The INDEX function returns a value or reference of the cell at the intersection of a particular row and column, in a given range.

INDEX(array, row_num, [column_num])

INDEX($B$3:$B$21, 1)

becomes

=INDEX({Federer,Roger; Djokovic,Novak; Murray,Andy; Davydenko,Nikolay; Roddick,Andy; DelPotro,JuanMartin; Federer,Roger; Davydenko,Nikolay; Verdasco,Fernando; Gonzalez,Fernando; Wawrinka,Stanislas; Gonzalez,Fernando; Blake,James; Nalbandian,David; Robredo,Tommy; Wawrinka,Stanislas; Cilic,Marin; Stepanek,Radek; Almagro,Nicolas}, 1)

and returns «Federer, Roger».

Relative and absolute cell references

When you copy the array formula down the countif formula range ($B$1:B1) expands. This is created by using relative and absolute references.

The first cell, B2: COUNTIF($B$1:B1,$A$2:$A$20)

Second cell, B3: COUNTIF($B$1:B2,$A$2:$A$20)

and so on.

Recommended reading:

Recommended articles

test

Back to top

10. How to filter unique values from a list

Picture of what unique values are

Unique values are values existing only once in a list. Example, «AA» exists twice in the list below and is not unique. BB and CC exist only once each and are unique in the list.

Column D in the picture below filters all unique values from column B. Unique values are values that exist only once in column B.

Extract a unique list1

Example, Roger, Federer is not in column D because there is more than one value of this name in column A. In other words, the name is not unique in column A. You can find the name twice in the list, in cells A2 and A8.

Update 2017-08-30 
This formula is even smaller than the array formula and you are not required to enter this as an array formula.

Regular formula in cell D3:

=LOOKUP(2, 1/((COUNTIF(D2:$D$2, $B$3:$B$21)=0)*(COUNTIF($B$3:$B$21, $B$3:$B$21)=1)), $B$3:$B$21)

Recommended articles

How to extract a case sensitive unique list from a column
Filter unique values sorted from A to Z
Extract unique values from two columns

Update 2020-12-09, the formula below extracts unique values from cell range $B$3:$B$21:

Regular formula in cell D3:

=UNIQUE($B$3:$B$21,,TRUE)

The formula above contains the new UNIQUE function that only Excel 365 subscribers can use. Use the formula above if you have an earlier Excel version.

Recommended articles

Extract unique values — Excel 365 (Link)
Extract unique values sorted from A to Z — Excel 365 (Link)
Extract unique values ignoring blanks — Excel 365 (Link)
Extract unique values sorted from A to Z ignoring blanks — Excel 365 (Link)

Array formula in cell D3:

=INDEX($B$3:$B$21, MATCH(0, COUNTIF(D2:$D$2, $B$3:$B$21)+(COUNTIF($B$3:$B$21, $B$3:$B$21)<>1), 0))

How to enter an array formula

Back to top

10.1 Explaining array formula in cell D3

Step 1 — Count each value in array and check if it is not equal to one

(COUNTIF($A$2:$A$20, $A$2:$A$20)<>1

becomes

{2;1;1;2;1;1;2;2;1;2;2;2;1;1;1;2;1;1;1}<>1

and returns

{TRUE; FALSE; FALSE; TRUE; FALSE; FALSE; TRUE; TRUE; FALSE; TRUE; TRUE; TRUE; FALSE; FALSE; FALSE; TRUE; FALSE; FALSE; FALSE}

This array tells excel that the first value in the array is not unique and that is true because Roger, Federer is not unique in the list. However the second value is FALSE and that value is unique, etc.

Recommended articles

test

Step 2 — Keep track of previous values

C1:$C$1 is a dynamic cell reference, it changes as the formula is copied to cells below. You can read more about absolute and relative cell references here:

Recommended articles

test

COUNTIF(C1:$C$1, $A$2:$A$20)

becomes

COUNTIF(«Unique list», {«Federer, Roger «; «Djokovic, Novak «; «Murray, Andy «; «Davydenko, Nikolay «; «Roddick, Andy «; «Del Potro, Juan Martin «; «Federer, Roger «; «Davydenko, Nikolay «; «Verdasco, Fernando «; «Gonzalez, Fernando «; «Wawrinka, Stanislas «; «Gonzalez, Fernando «; «Blake, James «; «Nalbandian, David «; «Robredo, Tommy «; «Wawrinka, Stanislas «; «Cilic, Marin «; «Stepanek, Radek «; «Almagro, Nicolas «})

and returns

{0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0}

A zero (0) means that no values have yet been displayed and that is true in cell C2. However when excel calculates the value in cell C3, cell C2 shows «Djokovic, Novak» and the array becomes {0; 1; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0}. The second value in the array contains 1. This tells excel that value has already been shown.

Step 3 — Add arrays

COUNTIF(C1:$C$1, $A$2:$A$20)+(COUNTIF($A$2:$A$20, $A$2:$A$20)<>1

becomes

{TRUE; FALSE; FALSE; TRUE; FALSE; FALSE; TRUE; TRUE; FALSE; TRUE; TRUE; TRUE; FALSE; FALSE; FALSE; TRUE; FALSE; FALSE; FALSE} + {0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0}

and returns

{1;0;0;1;0;0;1;1;0;1;1;1;0;0;0;1;0;0;0}

TRUE is 1 and FALSE is zero. So True + 0 equals 1 and False + 1 equals 1.

Step 4 — Find first zero value in array

A zero in the array indicates {1;0;0;1;0;0;1;1;0;1;1;1;0;0;0;1;0;0;0} that the corresponding value is unique and has not yet been displayed in the list.

MATCH(0, COUNTIF(C1:$C$1, $A$2:$A$20)+(COUNTIF($A$2:$A$20, $A$2:$A$20)<>1), 0)

becomes

MATCH(0, {1;0;0;1;0;0;1;1;0;1;1;1;0;0;0;1;0;0;0}, 0)

and returns 2.

Recommended articles

test

Step 5 — Return corresponding value

INDEX($A$2:$A$20, MATCH(0, COUNTIF(C1:$C$1, $A$2:$A$20)+(COUNTIF($A$2:$A$20, $A$2:$A$20)<>1), 0))

becomes

INDEX($A$2:$A$20, 2)

and returns «Djokovic, Novak» in cell C2.

Recommended articles

test

Back to top

10.2 Get Excel file

To extract duplicates, see this post:

Recommended articles

test

Back to top

11. Highlight unique values [Conditional Formatting]

Picture of unique highlighted values using conditional formatting

This example demonstrates how to highlight cells with a color of your choice if it contains a unique value.

11.1 Video

The following video shows you how to color unique values using conditional formatting. Remember, it highlights only unique values, in other words, values that exist only once in the list.

Subscribe to Get Digital Help on Youtube:

Instructions

  1. Go to tab «Home» on the ribbon
    Picture of how to highlight unique values using conditional formatting
  2. Press with left mouse button on «Conditional Formatting» button
  3. Hover over «Highlight Cell Rules»
  4. Press with mouse on «Duplicate Values…»
  5. Press with mouse on the leftmost drop-down list and change it to «Unique»
  6. Pick a formatting if you like
  7. Press with left mouse button on OK button

Picture of unique highlighted values using conditional formatting

The picture above shows you, for example, that the first name in the list has a duplicate so that name is not highlighted in any cell.

11.2 Sort unique values at the top

Tip! Did you know that you can put highlighted values to the top

  1. Press with right mouse button on on a highlighted cell
    Picture of how to put highlighted conditionally formatted values on top of list
  2. Press with mouse on «Sort»
  3. Press with mouse on «Put Selected Cell Color On Top»

Picture of unique highlighted values on top of list

Back to top

12. Useful tips

12.1 Excel tables

An Excel Table is a great feature and is very cleverly designed. It is constructed to automatically expand if you add more data which is incredibly helpful. You don’t need to do anything, not adjusting cell references which is time consuming and prone to errors.

Structured references are cell references to an excel defined table. They let you easily see what the data contains as long as you give it good descriptive column header names.

I recommend you use excel defined tables instead of named ranges or dynamic named ranges as long as you are working with more than one value.

Here is how to convert a list to an excel defined table:

  1. Select a cell in your list
  2. Go to tab «Insert» on the ribbon and press with left mouse button on Table button or press Ctrl + T
  3. Press with left mouse button on OK button
  4. Your excel defined table is created

Read more about excel defined tables

Back to top

12.2 Named ranges

In excel you can name a cell range, a constant or a formula. You can then use the named range in a formula, making it easier for you to read and understand formulas.

Example

List : A2:A20

Tip! Use dynamic named ranges to automatically adjust cell ranges when new values are added or removed.

12.2.1 How to create a named range

The downside with named ranges is that you need to adjust the range every time you add or delete a value in the list, the named range will then not fit the value list. I recommend using excel defined tables if you know that the list may change in the future.

  1. Select cell range B3:B7
  2. Type Color in name box
  3. Press Enter

Formula example containing name range:

=INDEX(Color,MATCH(0,COUNTIF($C$2:C2,Color),0))

Back to top

13. How to remove errors (Excel 2007)

Picture of values returned from a formula that extracts unique distinct values and no error values

Excel 2007 users (and later versions) can remove errors using IFERROR() function.

When the formula runs out of values it returns #N/A errors (Not Available), you can use the IFERROR function to remove the error and return blanks in those cells.

Unfortunately, it comes with a big disadvantage, it also removes other formula errors as well. So use this with great caution. If your source table has errors you won’t detect it because the IFERROR function returns a blank cell instead.

Array formula in cell D2:

=IFERROR(LOOKUP(2, 1/(COUNTIF($D$2:D2, $B$3:$B$21)=0), $B$3:$B$21), «»)

and copy it down as far as necessary.

Back to top

Recommended articles

How to use the IFERROR function
How to use the ISERROR function
How to use the ERROR.TYPE function
How to find errors in a worksheet
Delete blanks and errors in a list

Back to top

14. Excel 2003 users can remove errors using isna() function:

=IF(ISNA(INDEX($A$2:$A$20, MATCH(0, COUNTIF($B$1:B1, $A$2:$A$20), 0))), «», INDEX($A$2:$A$20, MATCH(0, COUNTIF($B$1:B1, $A$2:$A$20), 0)))

and copy it down as far as needed.

This formula is an array formula, how to enter an array formula.

Recommended article

  • ISNA function

Back to top

15. How to ignore blank cells in a range

Picture of values using a formula that extracts unique distinct values and ignores blank cells

Harlan Grove created a formula to count unique distinct values from a list with blanks. I used the same technique here to filter unique distinct values in column D.

If you want a header name you can use the slightly larger formula, displayed in column F below.

Update 2020-12-09, Excel 365 users can use this regular formula:

=UNIQUE(FILTER($B$3:$B$21, ($B$3:$B$21<>»») * ($B$3:$B$21<>»»)))

The formula below is actually 58 character while the new Excel 365 formula above is 61 characters, space characters not included. You can find a formula explanation here: Extract unique distinct values ignoring blanks

Use the formula below if you have an earlier Excel version than Excel 365.

Update 2017-09-01, smaller regular formula in cell D3:

=LOOKUP(2, 1/(COUNTIF($D$2:D2, $B$3:$B$21&»»)=0), $B$3:$B$21)

Formula in cell F3 if you need a column header name:

=LOOKUP(2, 1/((COUNTIF($F$2:F2, $B$3:$B$21)+($B$3:$B$21=»»))=0), $B$3:$B$21)

15.1 Watch a video where I explain how these two formulas work

Subscribe to Get Digital Help on Youtube:

This article shows you how to fill blank cells with values or formulas

Recommended articles

Learn how to extract non-blank cells in a list using a formula:

Recommended articles

test

Remove blank cells
In this blog post I will provide two solutions on how to remove blank cells and a solution on how […]

Back to top

15.2 Get Excel file

Back to top

Ok, I have two ideas for you. Hopefully one of them will get you where you need to go. Note that the first one ignores the request to do this as a formula since that solution is not pretty. I figured I make sure the easy way really wouldn’t work for you ;^).

Use the Advanced Filter command

  1. Select the list (or put your selection anywhere inside the list and click ok if the dialog comes up complaining that Excel does not know if your list contains headers or not)
  2. Choose Data/Advanced Filter
  3. Choose either «Filter the list, in-place» or «Copy to another location»
  4. Click «Unique records only»
  5. Click ok
  6. You are done. A unique list is created either in place or at a new location. Note that you can record this action to create a one line VBA script to do this which could then possible be generalized to work in other situations for you (e.g. without the manual steps listed above).

Using Formulas (note that I’m building on Locksfree solution to end up with a list with no holes)

This solution will work with the following caveats:

  • The list must be sorted (ascending or descending does not matter). Actually that’s quite accurate as the requirement is really that all like items must be contiguous but sorting is the easiest way to reach that state.
  • Three new columns are required (two new columns for calculations and one new column for the new list). The second and third columns could be combined but I’ll leave that as an exercise to the reader.

    Here is the summary of the solution:

    1. For each item in the list, calculate the number of duplicates above it.
    2. For each place in the unique list, calculate the index of the next unique item.
    3. Finally, use the indexes to create a new list with only unique items.

    And here is a step by step example:

    1. Open a new spreadsheet
    2. In a1:a6 enter the example given in the original question («red», «blue», «red», «green», «blue», «black»)
    3. Sort the list: put the selection in the list and choose the sort command.
    4. In column B, calculate the duplicates:
      1. In B1, enter «=IF(COUNTIF($A$1:A1,A1) = 1,0,COUNTIF(A1:$A$6,A1))». Note that the «$» in the cell references are very important as it will make the next step (populating the rest of the column) much easier. The «$» indicates an absolute reference so that when the cell content is copy/pasted the reference will not update (as opposed to a relative reference which will update).
      2. Use smart copy to populate the rest of column B: Select B1. Move your mouse over the black square in the lower right hand corner of the selection. Click and drag down to the bottom of the list (B6). When you release, the formula will be copied into B2:B6 with the relative references updated.
      3. The value of B1:B6 should now be «0,0,1,0,0,1». Notice that the «1» entries indicate duplicates.
    5. In Column C, create an index of unique items:
      1. In C1, enter «=Row()». You really just want C1 = 1 but using Row() means this solution will work even if the list does not start in row 1.
      2. In C2, enter «=IF(C1+1<=ROW($B$6), C1+1+INDEX($B$1:$B$6,C1+1),C1+1)». The «if» is being used to stop a #REF from being produced when the index reaches the end of the list.
      3. Use smart copy to populate C3:C6.
      4. The value of C1:C6 should be «1,2,4,5,7,8»
    6. In column D, create the new unique list:
      1. In D1, enter «=IF(C1<=ROW($A$6), INDEX($A$1:$A$6,C1), «»)». And, the «if» is being used to stop the #REF case when the index goes beyond the end of the list.
      2. Use smart copy to populate D2:D6.
      3. The values of D1:D6 should now be «black»,»blue»,»green»,»red»,»»,»».

    Hope this helps….

  • answered Sep 17, 2009 at 1:04

    Drew Sherman's user avatar

    Drew ShermanDrew Sherman

    8872 gold badges6 silver badges8 bronze badges

    4

    This is an oldie, and there are a few solutions out there, but I came up with a shorter and simpler formula than any other I encountered, and it might be useful to anyone passing by.

    I have named the colors list Colors (A2:A7), and the array formula put in cell C2 is this (fixed):

    =IFERROR(INDEX(Colors,MATCH(SUM(COUNTIF(C$1:C1,Colors)),COUNTIF(Colors,"<"&Colors),0)),"")
    

    Use Ctrl+Shift+Enter to enter the formula in C2, and copy C2 down to C3:C7.

    Explanation with sample data {«red»; «blue»; «red»; «green»; «blue»; «black»}:

    1. COUNTIF(Colors,"<"&Colors) returns an array (#1) with the count of values that are smaller then each item in the data {4;1;4;3;1;0} (black=0 items smaller, blue=1 item, red=4 items). This can be translated to a sort value for each item.
    2. COUNTIF(C$1:C...,Colors) returns an array (#2) with 1 for each data item that is already in the sorted result. In C2 it returns {0;0;0;0;0;0} and in C3 {0;0;0;0;0;1} because «black» is first in the sort and last in the data. In C4 {0;1;0;0;1;1} it indicates «black» and all the occurrences of «blue» are already present.
    3. The SUM returns the k-th sort value, by counting all the smaller values occurrences that are already present (sum of array #2).
    4. MATCH finds the first index of the k-th sort value (index in array #1).
    5. The IFERROR is only to hide the #N/A error in the bottom cells, when the sorted unique list is complete.

    To know how many unique items you have you can use this regular formula:

    =SUM(IF(FREQUENCY(COUNTIF(Colors,"<"&Colors),COUNTIF(Colors,"<"&Colors)),1))
    

    answered May 11, 2015 at 4:09

    dePatinkin's user avatar

    dePatinkindePatinkin

    2,2391 gold badge15 silver badges15 bronze badges

    5

    Solution

    I created a function in VBA for you, so you can do this now in an easy way.
    Create a VBA code module (macro) as you can see in this tutorial.

    1. Press Alt+F11
    2. Click to Module in Insert.
    3. Paste code.
    4. If Excel says that your file format is not macro friendly than save it as Excel Macro-Enabled in Save As.

    Source code

    Function listUnique(rng As Range) As Variant
        Dim row As Range
        Dim elements() As String
        Dim elementSize As Integer
        Dim newElement As Boolean
        Dim i As Integer
        Dim distance As Integer
        Dim result As String
    
        elementSize = 0
        newElement = True
    
        For Each row In rng.Rows
            If row.Value <> "" Then
                newElement = True
                For i = 1 To elementSize Step 1
                    If elements(i - 1) = row.Value Then
                        newElement = False
                    End If
                Next i
                If newElement Then
                    elementSize = elementSize + 1
                    ReDim Preserve elements(elementSize - 1)
                    elements(elementSize - 1) = row.Value
                End If
            End If
        Next
    
        distance = Range(Application.Caller.Address).row - rng.row
    
        If distance < elementSize Then
            result = elements(distance)
            listUnique = result
        Else
            listUnique = ""
        End If
    End Function
    

    Usage

    Just enter =listUnique(range) to a cell. The only parameter is range that is an ordinary Excel range. For example: A$1:A$28 or H$8:H$30.

    Conditions

    • The range must be a column.
    • The first cell where you call the function must be in the same row where the range starts.

    Example

    Regular case

    1. Enter data and call function.
      Enter data and call function
    2. Grow it.
      Grow it
    3. Voilà.
      Voilà

    Empty cell case

    It works in columns that have empty cells in them. Also the function outputs nothing (not errors) if you overwind the cells (calling the function) into places where should be no output, as I did it in the previous example’s «2. Grow it» part.

    Empty cell case

    answered Jun 27, 2013 at 7:43

    totymedli's user avatar

    totymedlitotymedli

    28.8k22 gold badges132 silver badges163 bronze badges

    5

    A roundabout way is to load your Excel spreadsheet into a Google spreadsheet, use Google’s UNIQUE(range) function — which does exactly what you want — and then save the Google spreadsheet back to Excel format.

    I admit this isn’t a viable solution for Excel users, but this approach is useful for anyone who wants the functionality and is able to use a Google spreadsheet.

    answered Jun 12, 2013 at 18:29

    yoyo's user avatar

    yoyoyoyo

    8,1704 gold badges56 silver badges49 bronze badges

    4

    noticed its a very old question but people seem still having trouble using a formula for extracting unique items.
    here’s a solution that returns the values them selfs.

    Lets say you have «red», «blue», «red», «green», «blue», «black» in column A2:A7

    then put this in B2 as an array formula and copy down =IFERROR(INDEX(A$2:A$7;SMALL(IF(FREQUENCY(MATCH(A$2:A$7;A$2:A$7;0);ROW(INDIRECT("1:"&COUNTA(A$2:A$7))));ROW(INDIRECT("1:"&COUNTA(A$2:A$7)));"");ROW(A1)));"")

    then it should look something like this;
    enter image description here

    Hashbrown's user avatar

    Hashbrown

    11.8k8 gold badges71 silver badges93 bronze badges

    answered Oct 26, 2014 at 1:14

    Jimmy's user avatar

    JimmyJimmy

    313 bronze badges

    Even to get a sorted unique value, it can be done using formula. This is an option you can use:

    =INDEX($A$2:$A$18,MATCH(SUM(COUNTIF($A$2:$A$18,C$1:C1)),COUNTIF($A$2:$A$18,"<" &$A$2:$A$18),0))
    

    range data: A2:A18

    formula in cell C2

    This is an ARRAY FORMULA

    Smajl's user avatar

    Smajl

    7,42728 gold badges109 silver badges175 bronze badges

    answered Sep 8, 2015 at 8:19

    new bie's user avatar

    Try this formula in B2 cell

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

    After click F2 and press Ctrl + Shift + Enter

    enter image description here

    answered Jul 6, 2017 at 9:33

    Hariharan G R's user avatar

    You could use COUNTIF to get the number of occurence of the value in the range . So if the value is in A3, the range is A1:A6, then in the next column use a IF(EXACT(COUNTIF(A3:$A$6, A3),1), A3, «»). For the A4, it would be IF(EXACT(COUNTIF(A4:$A$6, A3),1), A4, «»)

    This would give you a column where all unique values are without any duplicate

    answered Sep 15, 2009 at 22:20

    Locksfree's user avatar

    LocksfreeLocksfree

    2,67223 silver badges19 bronze badges

    Assuming Column A contains the values you want to find single unique instance of, and has a Heading row I used the following formula. If you wanted it to scale with an unpredictable number of rows, you could replace A772 (where my data ended) with =ADDRESS(COUNTA(A:A),1).

    =IF(COUNTIF(A5:$A$772,A5)=1,A5,»»)

    This will display the unique value at the LAST instance of each value in the column and doesn’t assume any sorting. It takes advantage of the lack of absolutes to essentially have a decreasing «sliding window» of data to count. When the countif in the reduced window is equal to 1, then that row is the last instance of that value in the column.

    answered May 22, 2013 at 4:53

    Geoff Still's user avatar

    Resorting to a PivotTable might not count as using formulas only but seems more practical that most other suggestions so far:

    SO1429899 example

    answered Jun 8, 2017 at 4:13

    pnuts's user avatar

    pnutspnuts

    58k11 gold badges85 silver badges137 bronze badges

    Drew Sherman’s solution is very good, but the list must be contiguous (he suggests manually sorting, and that is not acceptable for me). Guitarthrower’s solution is kinda slow if the number of items is large and don’t respects the order of the original list: it outputs a sorted list regardless.

    I wanted the original order of the items (that were sorted by the date in another column), and additionally I wanted to exclude an item from the final list not only if it was duplicated, but also for a variety of other reasons.

    My solution is an improvement on Drew Sherman’s solution. Likewise, this solution uses 2 columns for intermediate calculations:

    Column A:

    The list with duplicates and maybe blanks that you want to filter. I will position it in the A11:A1100 interval as an example, because I had trouble moving the Drew Sherman’s solution to situations where it didn’t start in the first line.

    Column B:

    This formula will output 0 if the value in this line is valid (contains a non-duplicated value). Note that you can add any other exclusion conditions that you want in the first IF, or as yet another outer IF.

    =IF(ISBLANK(A11);1;IF(COUNTIF($A$11:A11;A11)=1;0;COUNTIF($A11:A$1100;A11)))
    

    Use smart copy to populate the column.

    Column C:

    In the first line we will find the first valid line:

    =MATCH(0;B11:B1100;0)
    

    From that position, we search for the next valid value with the following formula:

    =C11+MATCH(0;OFFSET($B$11:$B$1100;C11;0);0)
    

    Put it in the second line and use smart copy to fill the rest of the column. This formula will output #N/D error when there is no more unique itens to point. We will take advantage of this in the next column.

    Column D:

    Now we just have to get the values pointed by column C:

    =IFERROR(INDEX($A$11:$A$1100; C11); "")
    

    Use smart copy to populate the column. This is the output unique list.

    answered Dec 20, 2013 at 23:07

    ReneSac's user avatar

    ReneSacReneSac

    5213 silver badges9 bronze badges

    You can also do it this way.

    Create the following named ranges:

    nList = the list of original values
    nRow = ROW(nList)-ROW(OFFSET(nList,0,0,1,1))+1
    nUnique = IF(COUNTIF(OFFSET(nList,nRow,0),nList)=0,COUNTIF(nList, "<"&nList),"")
    

    With these 3 named ranges you can generate the ordered list of unique values with the formula below. It will be sorted in ascending order.

    IFERROR(INDEX(nList,MATCH(SMALL(nUnique,ROW()-?),nUnique,0)),"")
    

    You will need to substitute the row number of the cell just above the first element of your unique ordered list for the ‘?’ character.

    eg. If your unique ordered list begins in cell B5 then the formula will be:

    IFERROR(INDEX(nList,MATCH(SMALL(nUnique,ROW()-4),nUnique,0)),"")
    

    Drunix's user avatar

    Drunix

    3,2938 gold badges28 silver badges50 bronze badges

    answered Apr 1, 2014 at 19:22

    dm64's user avatar

    dm64dm64

    112 bronze badges

    I’m surprised this solution hasn’t come up yet. I think it’s one of the easiest

    Give your data a heading and put it into a dynamic named range (i.e. if your data is in col A)

    =OFFSET($A$2,0,0,COUNTA($A:$A),1)
    

    And then create a pivot table, making the source your named range.

    Simply putting the heading into the rows section and you’ll have the unique values, sort any way you like with the inbuilt feature.

    Alex Szabo's user avatar

    Alex Szabo

    3,2742 gold badges22 silver badges30 bronze badges

    answered Sep 5, 2014 at 9:21

    CallumDA's user avatar

    CallumDACallumDA

    12k6 gold badges30 silver badges52 bronze badges

    I’ve pasted what I use in my excel file below. This picks up unique values from range L11:L300 and populate them from in column V, V11 onwards. In this case I have this formula in v11 and drag it down to get all the unique values.

    =INDEX(L$11:L$300,MATCH(0,COUNTIF(V$10:V10,L$11:L$300),0))
    

    or

    =INDEX(L$11:L$300,MATCH(,COUNTIF(V$10:V10,L$11:L$300),))
    

    this is an array formula

    Community's user avatar

    answered Mar 11, 2014 at 2:53

    user3404344's user avatar

    user3404344user3404344

    1,65715 silver badges12 bronze badges

    2

    Simple formula solution: Using dynamic array functions (UNIQUE function)

    Since fall 2018, the subscription versions of Microsoft Excel (Office 365 / Microsoft 365 app) contain so called dynamic array functions (not yet available in Office 2016/2019 nonsubscription versions).

    UNIQUE function

    One of those functions is the UNIQUE function that will deliver an array of unique values for the selected range.

    Example

    In the following example, the input values are in range A1:A6. The UNIQUE function is typed into cell C1.

    =UNIQUE(A1:A6)
    

    Simple solution to show unique values in Excel using dynamic array functions

    As you can see, the UNIQUE function will automatically spill over the necessary range of cells in order to show all unique values. This is indicated by the thin, blue frame around C1:C4.

    Good to know

    As the UNIQUE function automatically spills over the necessary number of rows, you should leave enough space under the C1. If there is not enough space, you will get a #SPILL error.

    Dynamic array functions: Spill not possible because a value in C3 is blocking the spill range

    If you want to reference the results of the UNIQUE function, you can just reference the cell containing the UNIQUE function and add a hash # sign.

    =C1#
    

    It is also possible to check unique values in several columns. In this case, the UNIQUE function will deliver all rows where the combination of the cells within the row are unique:

    Applying the UNIQUE function over several columns

    If you wish to show unique columns instead of unique rows, you have to set the [by_col] argument to TRUE (default is FALSE, meaning you will receive unique rows).

    You can also show values that appear exactly once by setting the [exactly_once] argument to TRUE:

    =UNIQUE(A1:A6;;TRUE)
    

    Show unique values that appear exactly once

    answered Jul 24, 2020 at 12:48

    Michael Wycisk's user avatar

    I ran into the same problem recently and finally figured it out.

    Using your list, here is a paste from my Excel with the formula.

    I recommend writing the formula somewhere in the middle of the list, like, for example, in cell C6 of my example and then copying it and pasting it up and down your column, the formula should adjust automatically without you needing to retype it.

    The only cell that has a uniquely different formula is in the first row.

    Using your list («red», «blue», «red», «green», «blue», «black»); here is the result:
    (I don’t have a high enough level to post an image so hope this txt version makes sense)

    • [Column A: Original List]
    • [Column B: Unique List Result]
    • [Column C: Unique List Formula]

      1. red, red, =A3
      2. blue, blue, =IF(ISERROR(MATCH(A4,A$3:A3,0)),A4,"")
      3. red, , =IF(ISERROR(MATCH(A5,A$3:A4,0)),A5,"")
      4. green, green, =IF(ISERROR(MATCH(A6,A$3:A5,0)),A6,"")
      5. blue, , =IF(ISERROR(MATCH(A7,A$3:A6,0)),A7,"")
      6. black, black, =IF(ISERROR(MATCH(A8,A$3:A7,0)),A8,"")

    t0mm13b's user avatar

    t0mm13b

    34k8 gold badges78 silver badges109 bronze badges

    answered Jan 3, 2013 at 1:29

    Chris Reedy's user avatar

    Chris ReedyChris Reedy

    4432 gold badges8 silver badges14 bronze badges

    This only works if the values are in order i.e all the «red» are together and all the «blue» are together etc.
    assume that your data is in column A starting in A2 — (Don’t start from row 1)
    In the B2 type in 1
    In b3 type =if(A2 = A3, B2,B2+1)
    Drag down the formula until the end of your data
    All » Red» will be 1 , all «blue» will be 2 all «green» will be 3 etc.

    In C2 type in 1, 2 ,3 etc going down the column
    In D2 = OFFSET($A$1,MATCH(c2,$B$2:$B$x,0),0) — where x is the last cell
    Drag down, only the unique values will appear. — put in some error checking

    answered May 9, 2014 at 11:55

    Brian's user avatar

    For a solution that works for values in multiple rows and columns, I found the following formula very useful, from http://www.get-digital-help.com/2009/03/16/unique-values-from-multiple-columns-using-array-formulas/
    Oscar at get-digital.help.com even goes through it step-by-step and with a visualized example.

    1) Give the range of values the label tbl_text

    2) Apply the following array formula with CTRL + SHIFT + ENTER, to cell B13 in this case. Change $B$12:B12 to refer to the cell above the cell you enter this formula into.

        =INDEX(tbl_text, MIN(IF(COUNTIF($B$12:B12, tbl_text)=0, ROW(tbl_text)-MIN(ROW(tbl_text))+1)), MATCH(0, COUNTIF($B$12:B12, INDEX(tbl_text, MIN(IF(COUNTIF($B$12:B12, tbl_text)=0, ROW(tbl_text)-MIN(ROW(tbl_text))+1)), , 1)), 0), 1)
    

    3) Copy/drag down until you get N/A’s.

    answered Jan 23, 2016 at 2:12

    Arthur Yip's user avatar

    Arthur YipArthur Yip

    5,6202 gold badges31 silver badges49 bronze badges

    If one puts all the data in the same columns and uses the following formula
    Example Formula: =IF(C105=C104,"Duplicate","Not a Duplicate")

    Steps

    1. Sort the data
    2. Add column for the formula
    3. Checks if the cell equals the cell above it
    4. Then filter Not a Duplicate
    5. Optional: Copy the data calculated by the formula column and paste as values only (that way if you start deleting data, you don’t start to get errors
    6. NOTE/WARNING: This only works if you sort the data first

    Example Formula: =IF(C105=C104,"Duplicate","Not a Duplicate")

    Richard Erickson's user avatar

    answered Mar 3, 2016 at 16:52

    Joseph A's user avatar

    Optimized VBScript Solution

    I used totymedli’s code but found it bogging down when using large ranges (as pointed out by others), so I optimized his code a bit. If anyone is interested in getting unique values using VBScript but finds totymedli’s code slow when updating, try this:

        Function listUnique(rng As Range) As Variant
            Dim val As String
            Dim elements() As String
            Dim elementSize As Integer
            Dim newElement As Boolean
            Dim i As Integer
            Dim distance As Integer
            Dim allocationChunk As Integer
            Dim uniqueSize As Integer
            Dim r As Long
            Dim lLastRow  As Long
    
            lLastRow = rng.End(xlDown).row
    
            elementSize = 1
            unqueSize = 0
    
            distance = Range(Application.Caller.Address).row - rng.row
    
            If distance <> 0 Then
                If Cells(Range(Application.Caller.Address).row - 1, Range(Application.Caller.Address).Column).Value = "" Then
                    listUnique = ""
                    Exit Function
                End If
            End If
    
            For r = 1 To lLastRow
                val = rng.Cells(r)
                If val <> "" Then
                    newElement = True
                    For i = 1 To elementSize - 1 Step 1
                        If elements(i - 1) = val Then
                            newElement = False
                            Exit For
                        End If
                    Next i
                    If newElement Then
                        uniqueSize = uniqueSize + 1
                        If uniqueSize >= elementSize Then
                            elementSize = elementSize * 2
                            ReDim Preserve elements(elementSize - 1)
                        End If
                        elements(uniqueSize - 1) = val
                    End If
                End If
            Next
    
    
            If distance < uniqueSize Then
                listUnique = elements(distance)
            Else
                listUnique = ""
            End If
        End Function
    

    answered Apr 13, 2016 at 0:53

    Meir Shachar's user avatar

    1

    Select the column with duplicate values then go to Data Tab, Then Data Tools select remove duplicate select
    1) «Continue with the current selection»
    2) Click on Remove duplicate…. button
    3) Click «Select All» button
    4) Click OK

    now you get the unique value list.

    answered Jun 3, 2014 at 10:03

    Zafar's user avatar

    There are a plethora of tutorials on how to identify and count unique values on the Excel work file. If you have read any of them, then you should know how to identify unique or distinct values in Excel. This is achieved in just three steps – identification, filtrating, and copying of the unique values. However, most of these methods are very cumbersome. But I will guide you through how to find and filter out unique values on the Excel column using special formulas and other quick methods.

    Before we zoom into the tutorial, it is Paramount that we familiarize ourselves with the meaning of unique values in Excel. In Excel, unique values are values that do not repeat. They are mentioned once in the list. Take a look at the image below to catch a glimpse of unique values.

    If you wish to bring to the fore, a list of unique values, you can use the formulas below:

    1. The Array formula:

    =IFERROR(INDEX($A$2:$A$10, MATCH(0, COUNTIF($B$1:B1,$A$2:$A$10) + (COUNTIF($A$2:$A$10, $A$2:$A$10)<>1), 0)), «»

    >> The array formula is executed by pressing «Ctrl + Shift + Enter»

    2. The regular formula:

    =IFERROR(INDEX($A$2:$A$10, MATCH(0,INDEX(COUNTIF($B$1:B1, $A$2:$A$10)+(COUNTIF($A$2:$A$10, $A$2:$A$10)<>1),0,0), 0)), «»)

    >> You will execute the regular formula when you press «Enter.»

    In the above formulas, the following references are used:

    • A2: A10 is the source list
    • B1 is the cell at the top of the unique list. Here, we begin the unique list from B2 and include B1 to the formula as stated – (B2-1=B1)
    • Now, in your own case, the unique list may start from cell C3. In such a case, change from $B$1:B1 to $C$2:C2.

    Here, our emphasis is on A2: A20 and we can use the formula to extract unique values from the Excel sheet as follows:

    1. Pick one of the formulas and tweak it in line with your data.

    2. After tweaking the formula, locate the first cell and enter the formula. In this example, it’s B2.

    3. Drag the fill handle to copy the formula down. Drag as far as you want.

    4. The unique values are embedded in the IFERROR, so you have the liberty to copy the formula down till you reach the end of the table. There are no issues with the number of unique values that you extract. Your data will not clutter with errors if the unique values are few.

    Using the Advanced Filter

    If you are not conversant with formulas, you can quickly select the unique values by using the advanced filter on Excel. We do so by following the steps below:

    1. Firstly, locate and select the column from which where you want to extract data from.

    2. Navigate to the Data tab.

    3. Proceed by clicking «Sort and filter group’‘. Go ahead and click the advanced button.

    4. After the advanced filter has opened, click the «Copy to another location» radio button.

    5. Check the list named «Range box,’‘ and complete the verification process to attest that the range is correct.

    6. Identify the box – «copy to», and the range of the destination. Enter in the topmost cell.

    7. After filtering your data, It’s only the active sheet that you can copy to.

    8. Identify all the unique values and select.

    9. Now, open the options for advance filter and configure accordingly.

    Lastly, select, Ok, and your result will display.

    Like this post? Please share to your friends:
  • Use definition to find word
  • Unique text count in excel
  • Upgrade works to word
  • Use day one in a sentence for each word
  • Unique one word names