The formula in cell D3 extracts unique distinct values sorted A to Z, from column B to column D. Unique distinct values are all values except duplicates.

Example, in column B value "DD" exists twice in cell B3 and B11. In column D value "DD" exists only once since it is a unique distinct list.

Array formula in cell D3:

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

Unique distinct list sorted alphabetically and based on a condition

The array formula in cell E6 filters values in column C based on value in cell E3, the output is […]

Comments(1) Filed in category: Excel, Sorted unique distinct values, VLOOKUP and return multiple values

How to create an array formula

  1. Double click on cell D3
  2. Copy (Ctrl +c) amd paste (Ctrl+v) above formula to cell D3
  3. Press and hold Ctrl + Shift simultaneously
  4. Press Enter once
  5. Release all keys

The formula in the formula bar should now look like this: {=formula}
Don't enter the curly brackets yourself, they appear automatically.

Learn the basics of Excel arrays

Array formulas allows you to do advanced calculations not possible with regular formulas.

Comments(2) Filed in category: Built-in features, Count values, Excel

How to copy array formula

  1. Select cell D3
  2. Copy cell  (Keyboard shortcut: Ctrl + c)
  3. Select cell range D4:D7
  4. Paste (Keyboard shortcut: Ctrl + v)

Explaining array formula in cell

Step 1 - Identify values not yet shown above current cell

Cell range $D$2:D2 changes as the formula is copied down to cells below. This makes it possible to avoid duplicate values in the list.

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

becomes

COUNTIF("Unique list sorted alphabetically",{"DD";"EE";"FF";"EE";"GG";"BB";"FF";"GG";"DD"})=0

becomes

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

and returns

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

COUNTIF function

Counts the number of times a value exists in a cell range.

Comments(5) Filed in category: Excel, Functions

Step 2 - Create an array with a ranking sort number

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

becomes

{1;3;5;3;7;0;5;7;1}

Step 3 - Convert array with not displayed values to an array containing rank numbers

IF(COUNTIF($D$2:D2,$B$3:$B$11)=0,COUNTIF($B$3:$B$11,"<"&$B$3:$B$11),"")

becomes

IF({TRUE; TRUE; TRUE; TRUE; TRUE; TRUE; TRUE; TRUE; TRUE},{1;3;5;3;7;0;5;7;1},"")

and returns

{1;3;5;3;7;0;5;7;1}

IF function explained

Check if a logical expression is met. Returns a specific value if TRUE and another specific value if FALSE.

Comments(9) Filed in category: Excel, Functions

Step 4 - Find the smallest value in array

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

becomes

SMALL({1;3;5;3;7;0;5;7;1},1)

and returns 0.

SMALL function and LARGE function

This function lets you extract any number in a cell range based on sort rank.

Comments(12) Filed in category: Excel, Functions

Step 5 - Find relative position in the array

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

becomes

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

becomes

MATCH(0,{1;3;5;3;7;0;5;7;1}, 0)

and returns 6.

MATCH function

Identify the position of a value in an array.

Comments(12) Filed in category: Excel, Functions

Step 6 - Return value in data based on row coordinate

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

becomes

INDEX($B$3:$B$11, 6)

becomes

INDEX({"DD"; "EE"; "FF"; "EE"; "GG"; "BB"; "FF"; "GG"; "DD"}, 6)

and returns BB in cell D3.

INDEX function explained

Fetch a value in a data set based on coordinates.

Comments(14) Filed in category: Excel, Functions, Index

Download excel sample file for this tutorial

Unique distinct list sorted alphabetically.xlsx

Recommended article

How to extract a unique distinct list from a column in excel

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

Comments(149) Filed in category: Advanced filter, Excel, Unique distinct values