# Use VLOOKUP and return multiple values sorted from A to Z

This article demonstrates how to extract multiple values based on a search value and display them sorted from A to Z.

The array formula in column G filters values in column C using a condition in cell E3, comparing it with values in adjacent column B. The filtered values are then sorted from A to Z.

It is possible to build a formula around the VLOOKUP function but it would be big, the following formula is smaller and easier to understand.

### Table of Contents

## 1. Extract multiple values based on a search value sorted from A to Z

This example demonstrates a formula that works in most Excel versions. The formula in cell G3 extracts values from column C if the corresponding value on the same row matches the search value specified in cell E3.

The result is sorted from A to Z and displayed in cell G3 and cells below as far as needed.

Array formula in cell G3:

### 1.1 Watch a video where I explain the formula

Recommended article

Recommended articles

This article demonstrates how to extract unique distinct values based on a condition and also sorted from A to z. […]

### 1.2 How to enter an array formula

- Double press with the left mouse button on cell G3.
- Copy and paste the above formula to cell G3.
- Press and hold CTRL + SHIFT simultaneously.
- Press Enter once.
- Release all keys.

Take a look at the formula bar and you will see that the formula now has a beginning and ending curly bracket.

Don't enter these characters yourself, they appear automatically. Example, {*=array_formula*}

The image above demonstrates the location of the formula bar.

### 1.3 Explaining formula in cell G3

#### Step 1 - Sort values in column C

COUNTIF($C$3:$C$10, "<"&$C$3:$C$10)

returns {3;6;4;2;1;5;7;0}

#### Step 2 - Extract sort rank numbers for chosen category

IF($E$3=$B$3:$B$10, COUNTIF($C$3:$C$10, "<"&$C$3:$C$10), "")

returns {3;"";4;"";1;5;"";""}

#### Step 3 - Find k-th smallest value in array

SMALL(IF($E$3=$B$3:$B$10,COUNTIF($C$3:$C$10,"<"&$C$3:$C$10),""),ROWS($A$1:A1))

SMALL({3;"";4;"";1;5;"";""},1) and returns 1.

#### Step 4 - Match sort rank to find relative position

MATCH(SMALL(IF($E$3=$B$3:$B$10, COUNTIF($C$3:$C$10, "<"&$C$3:$C$10), ""),ROWS($A$1:A1)), COUNTIF($C$3:$C$10,"<"&$C$3:$C$10), 0)

becomes MATCH(1, {3;6;4;2;1;5;7;0}, 0) and returns 5.

#### Step 5 - Return values

INDEX($C$3:$C$10,MATCH(SMALL(IF($E$3=$B$3:$B$10,COUNTIF($C$3:$C$10,"<"&$C$3:$C$10),""),ROWS($A$1:A1)),COUNTIF($C$3:$C$10,"<"&$C$3:$C$10),0))

becomes INDEX($C$3:$C$10,5) returns B in cell G3.

**Tip!** You can easily filter values if you convert your data to an excel table and then sort them:

Recommended articles

An Excel table allows you to easily sort, filter and sum values in a data set where values are related.

## 2. Extract multiple values based on a search value sorted from A to Z (Excel 365)

This example demonstrates a regular formula that works only in Excel 365. The formula is a dynamic array formula in cell G3, it returns multiple values that spills to cells below automatically.

It contains two functions, the FILTER function and the SORT function. It extracts values from column C if the value on the same row in column B matches the search value specified in cell E3.

Formula in cell G3:

### 2.1 Explaining formula

#### Step 1 - Filter values based on a condition

The FILTER function extracts values/rows based on a condition or criteria.

FILTER(*array*,Â *include*, [*if_empty*])

FILTER(C3:C10,E3=B3:B10)

returns {"F"; "G"; "B"; "N"}.

#### Step 2 - Sort result

The SORT function lets you sort values from a cell range or array.

SORT(*array*, [*sort_index*], [*sort_order*], [*by_col*])

SORT(FILTER(C3:C10,E3=B3:B10))

becomes

SORT({"F"; "G"; "B"; "N"})

and returns {"B"; "F"; "G"; "N"}.

### Vlookup and return multiple values category

This post explains how to lookup a value and return multiple values. No array formula required.

This article demonstrates an array formula that searches two tables on two different sheets and returns multiple results. Sheet1 contains […]

VLOOKUP a multi-column range and return multiple values.

### Excel categories

### 2 Responses to “Use VLOOKUP and return multiple values sorted from A to Z”

### 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

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form

Hii Oscar

I have a problem and I know you can help me definitely

"Am your way the great ..." this values with space in one cell (B1)

Is there any formula to seperate all strings in one raw like

C1- Am

C2- your

C3- way

C4- the

C5- great

C6-

C7-

Etc.

Anil

Yes there is but the formula is large:

https://www.get-digital-help.com/2011/03/23/text-to-columns-split-words-in-a-cell-excel-array-formula/

I recommend Rick Rothstein (MVP - Excel)'s formula:

https://www.get-digital-help.com/2011/03/23/text-to-columns-split-words-in-a-cell-excel-array-formula/#comment-52519