## Filter unique values sorted from A to Z

A **unique value** is a value that only exists once in a list.

A **unique distinct list** contains all cell values but duplicates are merged into one distinct cell value.

If your are looking for a unique distinct list array formula, see this blog article:

Create a unique distinct alphabetically sorted list

The following array formula extracts unique values from column B in cell D3 and below:

To enter an array formula, type the formula in a cell then press and hold CTRL + SHIFT simultaneously, now press Enter once. Release all keys.

The formula bar now shows the formula with a beginning and ending curly bracket telling you that you entered the formula successfully. Don't enter the curly brackets yourself.

### Explaining formula in cell D3

#### Step 1 - Identify unique values

The COUNTIF function counts cells in cell range based on a condition or criteria. If the value is equal to 1 then it must be a unique value.

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

becomes

COUNTIF({"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 "},{"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 "})=1

becomes

{2;1;1;2;1;1;2;2;1;2;2;2;1;1;1;2;1;1;1}=1

and returns

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

#### Step 2 - Build an array containing rank if list were sorted

The less than sign concatenated with the cell reference in the second argument in the COUNTIF function makes it return the rank number if list were sorted from A to Z.

COUNTIF($B$3:$B$21,"<"&$B$3:$B$21)

becomes

COUNTIF({"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 "},"<"&{"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 "})

becomes

COUNTIF({"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 "}, {"<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

{7; 6; 11; 3; 14; 5; 7; 3; 16; 9; 17; 9; 1; 12; 13; 17; 2; 15; 0}

#### Step 3 - Replace boolean value TRUE with rank number

The IF function returns one value (argument2) if TRUE and another (argument3) if FALSE.

IF(COUNTIF($B$3:$B$21,$B$3:$B$21)=1,COUNTIF($B$3:$B$21,"<"&$B$3:$B$21),"")

becomes

IF({FALSE; TRUE; TRUE; FALSE; TRUE; TRUE; FALSE; FALSE; TRUE; FALSE; FALSE; FALSE; TRUE; TRUE; TRUE; FALSE; TRUE; TRUE; TRUE},COUNTIF($B$3:$B$21,"<"&$B$3:$B$21),"")

becomes

IF({FALSE; TRUE; TRUE; FALSE; TRUE; TRUE; FALSE; FALSE; TRUE; FALSE; FALSE; FALSE; TRUE; TRUE; TRUE; FALSE; TRUE; TRUE; TRUE}, {7; 6; 11; 3; 14; 5; 7; 3; 16; 9; 17; 9; 1; 12; 13; 17; 2; 15; 0},"")

and returns

{""; 6; 11; ""; 14; 5; ""; ""; 16; ""; ""; ""; 1; 12; 13; ""; 2; 15; 0}.

#### Step 4 - Extract the smallest value

The SMALL function lets you calculate the k-th smallest value in a cell range or array. SMALL( *array*, *k*)

SMALL(IF(COUNTIF($B$3:$B$21, $B$3:$B$21)=1, COUNTIF($B$3:$B$21, "<"&$B$3:$B$21), ""), ROWS(D2:$D$2))

becomes

SMALL({""; 6; 11; ""; 14; 5; ""; ""; 16; ""; ""; ""; 1; 12; 13; ""; 2; 15; 0}, ROWS(D2:$D$2))

The ROWS function in the second argument has an expanding cell reference that grows when cell D3 is copied to cells below. This makes the formula return a new value in each cell except if duplicates exist in the list.

SMALL({""; 6; 11; ""; 14; 5; ""; ""; 16; ""; ""; ""; 1; 12; 13; ""; 2; 15; 0}, ROWS(D2:$D$2))

becomes

SMALL({""; 6; 11; ""; 14; 5; ""; ""; 16; ""; ""; ""; 1; 12; 13; ""; 2; 15; 0}, 1)

and returns 0 (zero).

#### Step 5 - Get position in array

The MATCH function finds the relative position of a value in an array or cell range.

MATCH(SMALL(IF(COUNTIF($B$3:$B$21, $B$3:$B$21)=1, COUNTIF($B$3:$B$21, "<"&$B$3:$B$21), ""), ROWS(D2:$D$2)), COUNTIF($B$3:$B$21, "<"&$B$3:$B$21), 0)

becomes

MATCH(0, COUNTIF($B$3:$B$21, "<"&$B$3:$B$21), 0)

becomes

MATCH(0, {7; 6; 11; 3; 14; 5; 7; 3; 16; 9; 17; 9; 1; 12; 13; 17; 2; 15; 0}, 0)

and returns 19.

#### Step 6 - Return value

The INDEX function returns a value based on row number (and column number if needed)

INDEX($B$3:$B$21, MATCH(SMALL(IF(COUNTIF($B$3:$B$21, $B$3:$B$21)=1, COUNTIF($B$3:$B$21, "<"&$B$3:$B$21), ""), ROWS(D2:$D$2)), COUNTIF($B$3:$B$21, "<"&$B$3:$B$21), 0))

becomes

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

and returns "Almagro, Nicolas " in cell D3.

### Download Excel *.xlsx file

Extract-a-unique-list sorted A to Z from a column-in-excel.xlsx

Table of Contents Sort a column using array formula Two columns sorting by the second column Sort alphanumeric values I […]

Sort dates within a date range

Array formula in D5: =SMALL(IF(($B$3:$B$12<=$E$3)*($B$3:$B$12>=$E$2), $B$3:$B$12, "A"), ROWS($A$1:A1)) How to create an array formula Copy array formula Select cell D5 […]

The image above shows a table with two columns in cell range B3:C16, it contains random text values in column […]

Sort column based on frequency

Question: How do I create a new unique distinct list from a column. I also want the list sorted from large […]

Sort text cells alphabetically from two columns

Table of Contents Sort text from two columns combined (array formula) Sort text from multiple cell ranges combined (user defined […]

5 easy ways to extract unique distinct values

You have quite a few options to choose from if you are looking for a way to create a unique […]

Count cells between a given value

jeyner asks: I need to count in a list the interval between the same value. Example list, 1-2-3-1-4-5-1-6-7-8-9-7-8-1 So the […]

Filter unique values and sort based on adjacent date

The formula in cell F3 extracts unique values from column C, the formula in cell F3 extracts the corresponding dates […]

Extract unique values from two columns

I read an article Merging Lists To A List Of Distinct Values at CPearson. The article describes code that you […]

List all unique events in a month

Question: I have a table with four columns, Date, Name, Level, and outcome. The range is from row 3 to […]

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Use the img tag, like this: <img src="Insert pic link here">

**Contact Oscar**

You can contact me through this contact form