I can’t begin to count the number of times I’ve created a unique list in Excel. I’ve used Remove Duplicates on the ribbon, PivotTables, and some fairly complex formulas. The UNIQUE function gives us a much simpler option, and because it works through Excel’s normal calculation process, the result updates automatically.
UNIQUE can return a distinct list of values, identify items that occur only once, compare multiple columns, and provide the headings for a simple formula-based report. It becomes even more useful when combined with Excel tables, SORT, TRANSPOSE, and COUNTIFS.
You can download the example workbook to work through the examples. These examples use dynamic array functionality available in Microsoft 365. UNIQUE is not available in Excel 2019 or earlier versions.
What You'll Learn
- UNIQUE returns distinct values by default, while exactly_once set to TRUE excludes every repeated item.
- Excel table references let UNIQUE results adjust automatically as source records are added or removed.
- UNIQUE can compare multiple columns or horizontal lists and work with SORT and TRANSPOSE.
- Spill references connect unique lists to data validation drop-downs and formula-based summary reports.
How the UNIQUE Function Works
UNIQUE is a dynamic array function. Rather than returning one value to one cell, it can return several values from a single formula. Excel places those results into the surrounding cells, a behavior known as spilling.
For example, enter this formula in cell G3 to get a distinct list of first names from B3:B10:
=UNIQUE(B3:B10)
Press Enter, and the results spill down from G3. There is no need to copy the formula into the cells below.
UNIQUE function syntax
The function has three arguments, with only the first required:
=UNIQUE(array,[by_col],[exactly_once])
- array: The range or array to assess and return values from.
- by_col: An optional argument controlling the direction of comparison. FALSE, or omitted, compares rows. TRUE compares columns.
- exactly_once: An optional argument controlling what counts as unique. FALSE, or omitted, returns one instance of each distinct item. TRUE returns only items that occur exactly once.
In most situations, we want a distinct list from data arranged vertically. For that, the default settings are perfectly fine. The next six examples show when to use those defaults and when to change them.
Example 1: Return Distinct Values or Items That Occur Only Once
The word “unique” can mean two different things. Understanding that difference is the key to using this function correctly.
Return one instance of each value
Our first-name list is in B3:B10. Jack and Chau each appear twice, while Sally, Billy, Ryan, and David each appear once.
In G3, enter:
=UNIQUE(B3:B10)
This returns a distinct list: every name is included, but each appears only once. Jack and Chau remain in the result, with their duplicate occurrences removed.
We have not supplied the exactly_once argument, so it defaults to FALSE.
Return only values that appear once
To exclude every name that appears more than once, enter this formula in I3:
=UNIQUE(B3:B10,,TRUE)
The two consecutive commas leave by_col at its default setting while allowing us to set exactly_once to TRUE.
The result contains only four names:
- Sally
- Billy
- Ryan
- David
Jack and Chau are excluded completely because each occurs twice in the source data.
The important distinction: leave exactly_once as FALSE for one of each item. Set it to TRUE only when you want items with no repetitions in the source.
Example 2: Create an Automatically Expanding List with an Excel Table
A formula referring to B3:B10 assesses that range. But what happens when the source data grows?
This is where Excel tables are particularly useful. Tables expand or contract as their rows are added or removed. By linking UNIQUE to a table column, the formula follows that changing source.
For an Excel table named tblExams with a first-name column headed First, enter this formula outside the source table:
=UNIQUE(tblExams[First])
When selecting the first-name cells inside the table, Excel uses a structured reference to the table column rather than a fixed cell reference.
Initially, the formula returns the same distinct list as before. Add the record for Dale Taylor to the table, and Dale automatically appears in the result.
There are two parts working together:
- The table reference adjusts to include the changing source data.
- The dynamic array result adjusts the number of cells needed for the distinct list.
That combination removes the need to keep editing the source range as new records arrive.
Example 3: Use UNIQUE with Multiple Columns
UNIQUE is not restricted to a single column. It can compare combinations of values across several columns, and we can choose how those columns appear in the result.
Method 1: Return adjacent columns
To return distinct first-name and last-name combinations from columns B and C, enter this formula in G3:
=UNIQUE(B3:C10)
The result spills into two columns. Excel compares each complete row of the selected range, rather than removing duplicates independently from each column.
This explains why Jack appears twice in the result: Jack Weber and Jack Wilson are different combinations. Their first names match, but their full records do not.
Method 2: Combine the values into one column
If we want full names in a single column, we can join the first and last names before UNIQUE assesses them:
=UNIQUE(B3:B10&" "&C3:C10)
The ampersands join each first name, a space, and the corresponding last name. UNIQUE then returns a distinct list of those combined names.
We get the same name combinations as the two-column method, but presented in one column.
Method 3: Return nonadjacent columns in a chosen order
What if the columns are not next to each other? In our example, we want the pass/fail result from column E first, followed by the first name from column B.
CHOOSE lets us assemble those ranges into a single array:
=UNIQUE(CHOOSE({1,2},E3:E10,B3:B10))
Here is how the formula fits together:
{1,2}tells CHOOSE to return two columns.E3:E10provides the first output column, containing pass/fail results.B3:B10provides the second output column, containing first names.- UNIQUE returns the distinct combinations from that assembled array.
This gives us control over both which columns are compared and the order in which they appear.
Example 4: Find Unique Values in a Horizontal List
So far, our records have been arranged vertically. UNIQUE can also work across a horizontal range, but we need to change the by_col argument.
Suppose D2:I2 contains repeated month headings. In K3, enter:
=UNIQUE(D2:I2,TRUE)
TRUE tells Excel to compare columns rather than rows. The result spills horizontally and returns the distinct month headings: February, March, and April.
Without that argument, Excel would compare rows. That is not the comparison we need for a list running across a single row.
Return the horizontal source as a vertical list
If the source is horizontal but we want the result vertically, wrap the formula in TRANSPOSE:
=TRANSPOSE(UNIQUE(D2:I2,TRUE))
UNIQUE first finds the distinct values across the source columns. TRANSPOSE then changes the result from horizontal to vertical.
by_col controls the comparison direction; TRANSPOSE changes the output orientation. They perform different jobs.
Example 5: Sort a Unique List and Use It in a Drop-Down
A distinct list is often more useful in alphabetical order, especially when it will become a data validation drop-down.
First, we can build a single-column list with the last name followed by a comma, a space, and the first name:
=UNIQUE(C3:C10&", "&B3:B10)
To sort that result alphabetically, wrap it in SORT. Enter the complete formula in G3:
=SORT(UNIQUE(C3:C10&", "&B3:B10))
For this example, SORT needs only the array to sort. Its default settings give us an alphabetically ordered list.
Use the entire spill range for data validation
We can now use the result as the source of a drop-down in L3:
- Select cell L3.
- Go to Data > Data Validation > Data Validation.
- Set Allow to List.
- In Source, enter
=$G$3#. - Click OK.
The hash symbol is important. G3# refers to the complete spill range starting at G3, not just G3 itself.
The drop-down now contains the sorted, distinct names. Using a spill reference means we do not have to specify a fixed ending cell for the list.
Example 6: Build a Simple Pivot-Style Report with UNIQUE and COUNTIFS
For our final example, we want to count the number of passes and fails for each month. We can create the row headings, column headings, and counts with just three formulas.
The source ranges are:
- D3:D10: The month labels for the exams.
- E3:E10: The pass/fail results.
Step 1: Create the row headings
In G3, enter:
=UNIQUE(E3:E10)
This produces the two distinct result categories, Pass and Fail, spilling vertically.
Step 2: Create the column headings
In H2, enter:
=TRANSPOSE(UNIQUE(D3:D10))
UNIQUE returns the distinct months from the vertical source range. TRANSPOSE turns that list horizontally so the months become the report’s column headings.
Step 3: Calculate all the counts
In H3, enter:
=COUNTIFS(E3:E10,G3#,D3:D10,H2#)
This formula uses two criteria pairs:
E3:E10,G3#matches the source results against the complete vertical list of Pass and Fail.D3:D10,H2#matches the source months against the complete horizontal list of month headings.
Because one criteria array is vertical and the other is horizontal, the counts spill across both dimensions. A single COUNTIFS formula fills the report beneath the month headings and beside the result categories.
Fantastic. We have a simple pivot-style report without manually typing the categories or copying a counting formula across every intersection.
Start with the Defaults, Then Build from There
For most duplicate-removal tasks, =UNIQUE(range) is all we need. The optional arguments become useful when we want to compare a horizontal list or return only items that occur exactly once.
The bigger benefit comes from combining UNIQUE with other Excel features. Tables keep the source reference flexible, SORT organizes the result, TRANSPOSE changes its direction, and spill references let data validation and COUNTIFS use the complete output.
That turns a task we might otherwise repeat manually into a formula-driven part of the workbook.


