Make a Sorted List of Unique Values in Excel
By ExcelReady TeamUpdated 6 min read
The short answer
To make a unique sorted list in Excel, wrap UNIQUE inside SORT: =SORT(UNIQUE(B2:B9)). UNIQUE removes the repeats and SORT puts what is left in A to Z order. The list spills down and updates when the data changes. Use =SORT(UNIQUE(B2:B9),,-1) for Z to A. Both functions need Excel 2021, Excel 2024 or Microsoft 365.
Key takeaways
- =SORT(UNIQUE(range)) returns each value once, in A to Z order, and updates by itself.
- Add -1 as SORT's third argument for Z to A: =SORT(UNIQUE(range),,-1).
- Blank cells show up as 0 in the list; wrap the range in FILTER to drop them.
- Refer to the whole list with the # sign, like E2#, to count or total each item beside it.
- In Excel 2019 or older, use Remove Duplicates or Advanced Filter, then sort A to Z.
On this page+
To make a unique sorted list in Excel, type =SORT(UNIQUE(B2:B9)) in an empty cell. UNIQUE keeps each value once, SORT puts the values in A to Z order, and the list updates by itself when the data changes. This guide is for anyone who needs a clean list of customers, products or regions for a summary table, a drop-down or a test question.
The formula for a unique sorted list#
The formula has two functions, one inside the other. Excel works from the inside out:
=SORT(UNIQUE(B2:B9))- UNIQUE(B2:B9) looks down the range and returns each value once, in the order it first appears.
- SORT(...) takes that shorter list and sorts it A to Z (or smallest to largest for numbers).
The result spills: it fills as many cells below as it needs. You type the formula in one cell only. Both functions need Excel 2021, Excel 2024 or Microsoft 365. In older versions you see #NAME?.
All the examples use this order list in A1:C9:
| A | B | C | |
|---|---|---|---|
| 1 | Order | Product | Qty |
| 2 | 1001 | Pens | 12 |
| 3 | 1002 | Stapler | 2 |
| 4 | 1003 | Folders | 30 |
| 5 | 1004 | Pens | 8 |
| 6 | 1005 | Tape | 5 |
| 7 | 1006 | Folders | 10 |
| 8 | 1007 | Pens | 20 |
| 9 | 1008 | Binders | 4 |
How to build the list step by step#
Pick an empty cell with empty cells below it, type the formula and press Enter. Here it goes in E2:
- Click E2.
- Type
=SORT(UNIQUE(and select B2:B9. Leave out the header in B1. - Type
))to close both functions and press Enter.
| UNIQUE alone | SORT(UNIQUE(...)) |
|---|---|
| Pens | Binders |
| Stapler | Folders |
| Folders | Pens |
| Tape | Stapler |
| Binders | Tape |
Eight rows became five. If you add order 1009 for "Labels" and extend the range, Labels appears between Folders and Pens on its own. The UNIQUE function guide and the SORT function guide list every optional argument. For a full introduction to UNIQUE, see how the UNIQUE function works.
How to sort the unique list Z to A or by count#
SORT takes up to four arguments: =SORT(array, sort_index, sort_order, by_col). To sort Z to A, set sort_order to -1 and leave sort_index empty:
=SORT(UNIQUE(B2:B9),,-1)The result is Tape, Stapler, Pens, Folders, Binders. The two commas skip sort_index, which then defaults to 1 (the first column).
To put the most common item first, sort by how many times each one appears. SORTBY can sort one list by another:
=SORTBY(UNIQUE(B2:B9),COUNTIF(B2:B9,UNIQUE(B2:B9)),-1)COUNTIF counts each unique product in the original column: Pens 3, Folders 2 and 1 for the rest. SORTBY then orders the products by those counts, highest first. So Pens comes first, then Folders, then the three products ordered once. For a ranked list of the biggest values instead, read about the top N list with SORT and FILTER.
How to skip blanks in a unique list#
Blank cells in the range appear as a 0 in the result, and SORT puts that 0 at the top. Remove blanks with FILTER before UNIQUE sees them:
=SORT(UNIQUE(FILTER(B2:B20,B2:B20<>"")))FILTER keeps only the cells that are not empty (<>"" means "not equal to nothing"). This is useful when you point the formula at a longer range, like B2:B20, to leave room for new rows.
Extra spaces cause a similar problem. "Pens" and "Pens " with a trailing space are two different values to UNIQUE. Clean them inside the formula with TRIM: =SORT(UNIQUE(TRIM(B2:B9))). UNIQUE is not case-sensitive, so "pens" and "Pens" already count as one.
How to add counts or totals next to the list#
Once the list is in E2, you can refer to the whole spilled list as E2#. The # is the spill range operator: it means "every cell this formula filled", even when the list grows. In F2, type:
=COUNTIF(B2:B9,E2#)This spills a count beside each product: Binders 1, Folders 2, Pens 3, Stapler 1, Tape 1. For total quantity, use SUMIF in G2:
=SUMIF(B2:B9,E2#,C2:C9)That gives Binders 4, Folders 40, Pens 40, Stapler 2, Tape 5. You now have a small summary table that updates with the data. To count how many distinct products there are, use =COUNTA(E2#), which returns 5. The article on counting unique values covers more ways to do that, including older versions.
A sorted unique list also makes a great source for a drop-down. See dynamic drop-down lists that update themselves.
How to make a unique sorted list in older Excel#
Excel 2019 and older don't have UNIQUE or SORT, so you build the list with menu commands. The result is a fixed list that doesn't update.
With Remove Duplicates#
- Copy the Product column to an empty column.
- With the copy selected, go to Data > Remove Duplicates and click OK.
- With the list still selected, go to Data > Sort A to Z.
With Advanced Filter#
- Click inside the data and go to Data > Advanced (in the Sort & Filter group).
- Choose Copy to another location, set the List range to B1:B9 and Copy to an empty cell.
- Tick Unique records only and click OK, then sort the new list A to Z.
Advanced Filter leaves your original data untouched. Remove Duplicates deletes rows from whatever you select, so always run it on a copy. The comparison of UNIQUE vs Remove Duplicates explains when each is the better choice.
Practise it#
A sorted list of distinct values is the first step of many summary tasks in job tests. Practise the UNIQUE function in a live spreadsheet: you type the formula and it checks it instantly. Then practise sorting with the SORT function and combine the two. Try the exercise on this page first: one formula, five products.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Your manager wants an alphabetical list of the products that were ordered. In E2, combine SORT and UNIQUE on B2:B9, then press Enter.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Qty | Products A-Z | ||||
| 2 | ||||||
| 3 | ||||||
| 4 | ||||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 8 | ||||||
| 9 | ||||||
| 10 | ||||||
| 11 | ||||||
| 12 |
Tip: UNIQUE goes on the inside to remove repeats. SORT goes on the outside to put them in order.
Practise this in a lesson
Frequently asked questions
How do I get a list of unique values in alphabetical order in Excel?
Use =SORT(UNIQUE(range)), for example =SORT(UNIQUE(B2:B9)). It returns every distinct value once, sorted A to Z, and spills down from the cell you type it in.
How do I sort a unique list in descending order?
Give SORT a sort order of -1 and leave the second argument empty: =SORT(UNIQUE(B2:B9),,-1). The two commas skip the sort index, which defaults to the first column.
Why is there a 0 in my unique list?
Your range includes an empty cell, and UNIQUE returns it as 0. Filter the blanks out first: =SORT(UNIQUE(FILTER(B2:B20,B2:B20<>""))).
How do I make a sorted unique list without the UNIQUE function?
Copy the column to a new place, use Data > Remove Duplicates, then sort it A to Z. Advanced Filter with Unique records only also works and keeps the original data unchanged.
Is UNIQUE case-sensitive?
No. UNIQUE treats pens, Pens and PENS as the same value and keeps the first one it finds. Extra spaces do count, so "Pens " with a trailing space is a separate item.