I can’t even begin to count the number of times I have created a unique list in Excel. I have performed it manually using the remove duplicates from the ribbon, Pivot Tables and using complex formulas, but that is now a thing of the past. When Microsoft announced changes to Excel’s calculation engine in September 2018, they also announced a host of new functions, one of which is UNIQUE.

At the time of writing, the UNIQUE function is only available to those on a Microsoft 365 subscription. It will not be available in Excel 2019 or earlier versions.

**Download the example file**

I recommend you download the example file for this post. Then you’ll be able to work along with examples and see the solution in action, plus the file will be useful for future reference.

Download the file: 0032 UNIQUE function in Excel.zip

**Watch the video:**

Contents

## The arguments of the UNIQUE function

The UNIQUE function is straightforward to apply, as shown by the animation below.

UNIQUE has just three arguments. The last two are optional arguments and quite obscure, so you will only use them occasionally.

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

**array:**the range or array to return values from.**[by_col]:**an optional argument where FALSE = compare by row and TRUE = compare by column. If excluded, the argument will default to FALSE. The impact of this is demonstrated in Example 4.**[exactly_once]:**This argument depends on your interpretation of the word*unique*. If you want a list that includes only the items that appear once, then use TRUE. If you want a list that contains one instance of each item (i.e., a distinct list), then use FALSE. This is an optional argument and if excluded, will default to FALSE. The impact of this is demonstrated in Example 1.

**Formula Magic with Dynamic Arrays**

Of all the features available in Excel dynamic arrays provide the most power for the smallest time investment. Yet most Excel users do not even know what they are.

Have you ever faced these spreadsheet scenarios?

- How can I
**use VLOOKUP to return all the matching items**, not just the first? - How can I
**sort my information using a formula**, so I don’t have to keep clicking the sort button? - How can I quickly
**create unique lists**of items to use with my SUMIFS calculation? - How can I
**stop copying down formulas every time my source data changes.** - How can I build a
**PivotTable-like report, but using formulas**so I don’t have to click refresh ever again.

Well, I’m here to give you some good news. with dynamic arrays, all these can be achieved easily 🙂

## Examples of using the UNIQUE function

The following examples illustrate how to use the UNIQUE function.

### Example 1 – The difference between unique and distinct

The last argument of the UNIQUE function determines if it returns a distinct or unique list.

**Distinct list**

The formula in cell C3 is:

=UNIQUE(B3:B10)

As the third argument has not been used, exactly_once has defaulted to FALSE and therefore shows a list of distinct results. Sally, Jack, Billy, Ryan, Chau and David all appear in cells B3-B10; therefore, we get a list of all those names.

**Unique list (exactly once)**

The formula in cell G3 is:

=UNIQUE(B3:B10,,TRUE)

The third argument is TRUE, therefore UNIQUE will return the results which appear only once in the array. Sally, Billy, Ryan, and David all appear once within cells B3-B10. However, Jack and Chau appear twice and are excluded from the result.

**The difference between distinct and unique lists**

When using the exactly_once argument, this is an important difference to understand:

- FALSE or empty = a distinct list
- TRUE = a list of items occurring only once

My guess is that in most situations, we will be using the distinct version of UNIQUE, which is the default option anyway.

### Example 2 – UNIQUE linked to an Excel table

Example 2 shows how UNIQUE responds when linked to an Excel table. When a new record is added, UNIQUE automatically expands to include the additional value in the spill range. Notice that the spill range of the UNIQUE function updates as soon as new items are added to the table.

The formula in cell G3 is:

=UNIQUE(tblExam[First])

As the UNIQUE function is referencing the entire column, when the column expands or retracts, so does the result of the formula.

### Example 3 – UNIQUE across 2 columns

UNIQUE is not restricted to a single column.

**Method 1**

This returns the unique list and retains the same number of columns as included in the first argument.

The formula in cell G3 is:

=UNIQUE(B3:C10)

This includes the First and Last name columns in the array and returns both in the result. One instance of *Chau Yang* has been excluded as it appears twice in the source list.

**Method 2**

The second method uses functionality from the new calculation engine to concatenate columns together before applying the UNIQUE function.

The formula in cell G3 is:

=UNIQUE(B3:B10&" "&C3:C10)

Again, one instance of *Chau Yang* has been removed to provide a unique list within a single column.

**Method 3**

Sometimes we want a unique list with two columns that are not next to each other. In this circumstance, we can use the CHOOSE function to reorder the columns.

The formula in cell G3 is:

=UNIQUE(CHOOSE({1,2},E3:E10,B3:B10))

By using CHOOSE, we have defined the first array as E3-E10 and the second array as B3-B10. These are the ranges that have been returned within the spill range.

### Example 4 – Using UNIQUE across columns

By default, Excel assumes UNIQUE should be applied on a vertical list. However, it can also work on a horizontal list.

**Horizontal list**

In the example above, cell K3 contains the following formula.

=UNIQUE(D2:I2,TRUE)

The second argument of TRUE is used to tell the function that the data is in a horizontal format.

**Use TRANSPOSE to convert horizontal & vertical (and vice versa)**

If we had a vertical or horizontal list that we wanted to flip, we could use the TRANSPOSE function.

The formula in cell K3 is:

=TRANSPOSE(UNIQUE(D2:I2,TRUE))

TRANSPOSE is used to change our horizontal UNIQUE list so the output is vertical.

### Example 5 – Combining UNIQUE with SORT in a data validation list

Example 5 demonstrates how to combine the UNIQUE and SORT functions together.

The formula in cell G3 is:

=SORT(UNIQUE(C3:C10&", "&B3:B10))

The formula returns an alphabetically sorted unique list based on the last name and first names combined.

Often the purpose of a unique sorted list is for use within a data validation drop-down list. To do this, we can use the # symbol after the cell reference to refer to the entire spill range.

In the screenshot above, the formula is contained in cell G3. Therefore *=G3# *has been used as the source for a data validation list. When the spill range increases or decreases in size, so does the drop-down list. It’s like magic!

### Example 6 – Simple formula based Pivot Report

As a final example, we can create a simple Pivot Report using UNIQUE combined with some other common functions.

The formula in cell G3 is:

=UNIQUE(E3:E10)

This is the standard UNIQUE function applied to the Pass/Fail column.

The formula in cell H2 is:

=TRANSPOSE(UNIQUE(D3:D10))

TRANSPOSE switches the output of UNIQUE from displaying in rows to displaying in columns. The 3 distinct dates in the Exam Date column are now listed as column headers.

The formula in H3 is:

=COUNTIFS(E3:E10,G3#,D3:D10,H2#)

The COUNTIFS function includes the # references, so it automatically spills in the same way as the cells it is dependent upon.

With 3 simple formulas we have created a complete report – amazing!. Remember, if the source is an Excel table, the output will expand as new data is added – even more amazing!!

### Want to learn more?

There is a lot to learn about dynamic arrays and the new functions. Check out my other posts here to learn more:

- Introduction to dynamic arrays – learn how the excel calculation engine has changed.
- UNIQUE – to list the unique values in a range
- SORT – to sort the values in a range
- SORTBY – to sort values based on the order of other values
- FILTER – to return only the values which meet specific criteria
- SEQUENCE – to return a sequence of numbers
- RANDARRAY – to return an array of random numbers
- Using dynamic arrays with other Excel features – learn to use dynamic arrays with charts, PivotTables, pictures etc.
- Advanced dynamic array formula techniques – learn the advanced techniques for managing dynamic arrays

**Get our FREE VBA eBook of the 30 most useful Excel VBA macros.**

Automate Excel so that you can save time and stop doing the jobs a trained monkey could do.

*By entering your email address you agree to receive emails from Excel Off The Grid. We’ll respect your privacy and you can unsubscribe at any time.*

**Don’t forget:**

If you’ve found this post useful, or if you have a better approach, then please leave a comment below.

**Do you need help adapting this to your needs?**

I’m guessing the examples in this post didn’t exactly meet your situation. We all use Excel differently, so it’s impossible to write a post that will meet everybody’s needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site) you should be able to adapt it to your needs.

But, if you’re still struggling you should:

- Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
- Ask the ‘Excel Ninja’ in your office. It’s amazing what things other people know.
- Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it’s clear and concise. List all the things you’ve tried, and provide screenshots, code segments and example workbooks.
- Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.

What next?

Don’t go yet, there is plenty more to learn on Excel Off The Grid. Check out the latest posts:

Hey Mark,

I’m going over each of these Dynamic Array lessons multiple times as it takes me a bit to “get it”, but it is worth the time. For this UNIQUE function video, when I use the UNIQUE formula with an existing table I created and I select the data range in a single column like you are doing in your video, the syntax of the formula does not look that same as your example (sorry for the run-on sentence). However, if I select the whole column it does look the same. Am I safe to select the whole column? BTY, the table is on a separate tab, and when I select the cells in the column the syntax points to the tab name but when I select the entire column the syntax shows the table name and column header (like your example)…maybe because the table is it’s own tab the behaviour is a bit different?

Again, thanks heaps for the videos…they are great!

Hi Keith – I think your question might be more related to working with Tables than to Dynamic Arrays specifically.

A Table is a container for data. Excel thinks about Tables only in terms of columns, which is why the format is myTable[myColumnName]. But if you select any range which is not a full Table column, then it reverts back to the standard referencing (e.g. D4:D10)

Table names used in a workbook are all unique, therefore it does not need a sheet name to be included, because Excel knows which Table you’re referring to. However cell A1 exists on every sheet, so it needs a sheet name, otherwise, Excel doesn’t know which A1 you’re referring to.

It is completely safe to select an entire Table column, and in my opinion, is a superior method to using standard ranges.

I did a presentation to the Toronto Excel Meetup a while back, which might be interesting to you. It looks at different ways of using ranges in Excel. You can find it here: https://www.youtube.com/watch?v=kyU702xwcxM&t=486s

I’ve also got a few posts about Tables that might be useful:

https://exceloffthegrid.com/dynamically-select-any-column-in-an-excel-table/

https://exceloffthegrid.com/using-an-excel-table-within-a-data-validation-list/

https://exceloffthegrid.com/excel-tables-absolute-references/

https://exceloffthegrid.com/create-a-running-total-in-an-excel-table/

My friend John MacDougall also as a very detailed guide to Tables:

https://www.howtoexcel.org/tutorials/everything-you-need-to-know-about-excel-tables/

I hope all this helps 🙂

Awesome, thanks heaps.

You’re welcome Keith. Glad it helped 😊

I’m looking for a way to make the Unique spill horizontally instead of vertically. Is there a way to do that?

Just wrap it in the TRANSPOSE() function.

My office in excel it don’t have formula UNIQUE function

I’m so sad.

UNIQUE is pretty good isn’t it.

If you’ve not got a dynamic array enabled version of Excel there is another less dynamic option, but it’s a bit of a mind bender:

https://exceloffthegrid.com/list-unique-or-duplicate-values-with-excel-formulas/