## How to use the MATCH function

*Article updated on April 19, 2018*

Returns the relative position of an item in an array that matches a specified value in a specific order.

The formula in cell D10 searches for value "A" in cell range C3:C7 and finds an exact match in cell C5. The relative position of C5 in cell range C3:C7 is 3, shown in column B.

The formula returns 3 in cell D10, remember to use 0 (zero) in the third argument if you want to find an exact match.

### Excel Function Syntax

**MATCH(***lookup_value*, *lookup_array*, *[match_type]*)

### Arguments

lookup_value |
Required. Is the value you use to find the value you want in the array, a number, text or logical value, or a reference to one of these. |

lookup_array |
Required. Is a contiguous range of cells containing possible lookup values, an array of values, or a reference to an array. |

[match_type] |
Optional. How to match, a number -1,0,1. If omitted number 1 is used. |

**match_type**

-1 |
Finds the largest value that is less than or equal to lookup_value. Lookup_array must be placed in ascending order |

0 |
Finds the value that is exactly equal to lookup_value. Lookup_array can be in any order |

1 |
Finds the smallest value that is greater than or equal to lookup_value. Lookup_array must be placed in descending order |

### Comments

- The lookup_array must be a one dimensional horizontal or vertical cell range
- The lookup_value can also be an array, one or two dimensional. (array formula)
- The lookup_array can be one value. (array formula)
- You can use other excel functions in the lookup_value argument.
- You can use other excel functions in the lookup_array argument. As long as they return a one-dimensional array.
- I use match_type = 0 almost all the time.

#### Table of Contents

- Lookup_array in ascending order
- Lookup_array in any order
- Lookup_array in descending order
- Array formula
- Using wildcard character
- VBA Example
- Download excel *.xlsx file

### Example 1 - Lookup_array in ascending order

=MATCH(C17, C19:C21,1)

becomes

MATCH(2, {1; 5; 10; 12},1)

Match_type 1 - Find the **largest** value {1; 5; 10; 12} that is **less** or **equal** to lookup_value (2)

MATCH(2, {**1**; 5; 10; 12},1)

The relative position of number 1 in array {1; 5; 10; 12} is 1. 1 is returned in cell D14.

### Example 2 - Lookup_array in any order

=MATCH(C17, C19:C21,0)

becomes

MATCH(1, {10; 12; 1; 5},0)

Match_type 1 - Find the **first** value {10; 12; 1; 5} that is **exactly** **equal** to lookup_value (1)

MATCH(1, {10; 12; **1**; 5},0)

The relative position of number 1 in array {10; 12; 1; 5} is 3. 3 is returned in cell D14.

### Example 3 - Lookup_array in descending order

=MATCH(C17, C19:C21,-1)

becomes

MATCH(2, {12; 10; 5; 1},-1)

Match_type 1 - Find the **smallest **value {12; 10; 5; 1} that is **greater than **or **equal** to lookup_value (2)

MATCH(2, {12; 10; **5**; 1},-1)

The relative position of number 5 in array {12; 10; **5**; 1} is 3. 3 is returned in cel D14.

### Example 4 - Array formula

=MATCH(C19:C22, D19:D22,0)

becomes

MATCH({12;1;10;5}, {10; 12; 1; 1},0)

Match_type 1 - Find the **first** value {10; 12; 1; 1} that is **exactly** **equal** to lookup_value {12;1;10;5}

Lookup value 12 is the **second** value in the lookup_array {10; **12**; 1; 1}.

Lookup value 1 is the **third** value in the lookup_array {10; 12; **1**; 1}.

Lookup value 10 is the **first **value in the lookup_array {**10**; 12; 1; 1}.

Lookup value 5 is not found in the lookup_array {10; 12; 1; 1}.

{2; 3; 1; #N/A} is returned in cell range B19:B22.

### Wildcard character

fghdfn

### VBA Example

The following macro uses the MATCH function to find the position of the lookup value in cell range C5:C8. It then displays a message box containing that position.

**VBA code**

Sub VBA_MATCH() MsgBox Application.WorksheetFunction.Match(Range("C2"), Range("C5:C8"), 0) End Sub

### Download excel *.xlsx file

### Articles with the 'MATCH' Function

The following 20 articles have formulas that contain the MATCH function.

### Functions in 'Lookup and reference'

The MATCH function function is one of many functions in the 'Lookup and reference' category.

### 12 Responses to “How to use the MATCH function”

### Leave a Reply

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

<code>your formula</code>

Remember to convert less than and larger than signs to html character entities before you post your comment.

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

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

VBA code

[/vb]

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

Upload picture to postimage.org

Add picture link to comment.

**Contact Oscar**

You can contact me through this webpage

[...] MATCH(lookup_value;lookup_array; [match_type]) Returns the relative position of an item in an array that matches a specified value [...]

Oscar,

You might want to read the comments of the below post to see couple of more interesting uses of the MATCH Function

https://fastexcel.wordpress.com/2013/02/27/speedtools-avlookup2-memlookup-versus-vlookup-performance-power-and-ease-of-use-shootout-part-1/#comments

sam,

Very interesting comment! I never thought of that.

Thank you for commenting!

Respected sir,

You solved one of my excel related problem some months back. This time I have another problem. This time I have some fields as below:

Capacity City books Big_Boxes small_Boxes Total

90 Kanpur 400 4 1 5

Lucknow 690 7 1 8

Jhansi 240 2 1 3

Allahabad 20 0 1 1

Total 17

Now, I have to generate slips to paste on boxes which are to be despatched:

City: Kanpur

No_of_Text_Books in this Box 90 Box No.1

Total_No._of_Books 400 in 5 Boxes

These slips are to be generated till end. Please help me.

neeraj kumar,

Formula in cell A10:

Formula in cell A11:

Download excel *.xlsx file

neeraj-kumar.xlsx

[…] MATCH(lookup_value, lookup_array, [match_type] Returns the relative position of an item in an array that matches a specified value […]

[…] MATCH(lookup_value, lookup_array, [match_type] Returns the relative position of an item in an array that matches a specified value. […]

[…] Match function […]

[…] and returns 2. Read more about MATCH function. […]

[…] MATCH(lookup_value;lookup_array, [match_type]) Returns the relative position of an item in an array that matches a specified value […]

[…] MATCH(lookup_value,lookup_array, [match_type]) Returns the relative position of an item in an array that matches a specified value […]