The MATCH function is a computer program that you run from a worksheet cell formula. It looks up a value you designate within a group of values and returns the position of that value within the group. The group of values being scanned are generally located in a given worksheet area (called a range). You run the MATCH worksheet function by typing its name in a formula then followed by the information it is suppose to use. The MATCH worksheet function is generally not used by itself. It is generally used to return some position so another function or formula can use that information. The match function is very commonly used with the INDEX worksheet function as a replacement for the VLOOKUP function (refer to INDEX for further information). MATCH generally scans a single worksheet row or column to find the position of name, number, date...etc. Remember though the position returned is relative to the range start and end which means if you look at a range C3:C10 and find Widget3 in C3, MATCH returns 1 because cell C3 is the first cell in the range being scanned. If the range started at C1 then it would return 3 because it is the 3 cells down.

Whenever you type a formula in a worksheet cell, this is called syntax or grammar. The general MATCH function syntax has a format like this when you type it in a worksheet cell:

=MATCH(lookup_value,lookup_array,[match_type])

Where lookup_value, lookup_array, [match_type] are called the function argument list. Remember, you are running a computer program at this point so the program needs information to operate and that is why there is an argument list. When you see an argument list and you see square brackets [ ] around the argument name, this means the argument is optional and you do not have to include it when typing unless you need it. So for the syntax above, you need to include 2 arguments for the MACTH worksheet function when typing it in a worksheet cell formula in order for it to calculate correctly. What argument values can be used are discussed below. Remember functions expect certain things in their argument lists, if you do not put the correct information in the list they will generate an error when run.

- lookup_value: This is the value (text, number,...etc) you use to find the value you want in a worksheet column or row.
- lookup_array: This is a contiguous range of cells, row or column, containing possible lookup values. It can also be an array.
- match_type (Optional): This
can be three preset numbers, -1, 0 or 1. Match_type
specifies how Microsoft Excel matches lookup_value with
values in lookup_array. Do not default this value, always
include it! If you are searching for a specific value which
is the case in most instances, always put 0 or you might end
up with the wrong match.
- If match_type is 1, MATCH finds the largest value that is less than or equal to lookup_value. The row or column scanned must be placed in ascending order: ...-2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE.
- If match_type is 0, MATCH finds the first value that is exactly equal to lookup_value. The row or column scanned can be in any order.
- If match_type is -1, MATCH finds the smallest value that is greater than or equal to lookup_value. The row or column scanned must be placed in descending order: TRUE, FALSE, Z-A, ...2, 1, 0, -1, -2, ..., and so on.
- If match_type is omitted, it is assumed to be 1. Do not do this!

Since the MATCH function is a computer program, it runs when you press Enter to enter the formula that contains it. If any of the arguments are wrong, the function will return an error.

When typing the MATCH function in a worksheet cell formula, you need to replace the argument list with arguments separating each one with a comma (,). Some typical arguments you can use are:

Cell Formula | Example Explanation |

=MATCH("Widget1",A1:A5,0) | Find Widget1 in A1:A5 then returns position 1 through 5 depending on what cell contains it |

=MATCH("*ST*",J9:J15,0) | Find the piece of text ST inside the cell value text in J9 to J15 then return position 1 through 7 depending on what cell contains it |

=MATCH("*" & B1 & "*",G1:G5,0) | Find the piece of text from the B1 cell value inside the text in G1 to G5 then return position 1 through 5 depending on what cell contains it |

=MATCH(16,A1:G1,0) | Find the number 16 in A1 to G1 then return position 1 through 7 depending on what cell contains it |

=MATCH(B1,Prices,0) | Find the B1 cell value in range name Prices then return position* |

* It is possible to name a cell or group of cells on a worksheet and use that name in place of a range reference or cell reference. Consult Excel help on how to name a cell.

The worksheet seen below contains some typical worksheet formulas that run the MATCH worksheet function. Pay close attention to the argument list and the syntax used to write the formula.

A | B | C | |

1 | |||

2 | |||

3 | Item | Q1 | |

4 | X | 100 | |

5 | Y | 200 | |

6 | Z | 300 | |

7 | |||

8 | = VLOOKUP("X" , A3:B6, MATCH( "Q1", A3:Z3, 0 ) , FALSE ) | MATCH is used to find the position of the table header Q1 in the range A3 to Z3 so the VLOOKUP function can automatically adjust where to retrieve its answer if more columns are added to the table. The value returned by MATCH is 2 so the value returned will be 100. The problem always assumes the table will start in column A so you can stretch the range reference past the table boundaries | |

9 | |||

10 | |||

11 | Date | Item | Quantity |

12 | 1/1/2015 | X | 100 |

13 | 1/2/2015 | Y | 200 |

14 | 1/3/2015 | Z | 300 |

15 | |||

16 | |||

17 | = INDEX( A11:C14, MATCH( "Y", B11:B14, 0) , MATCH( "Quantity", A11:C11, 0 ) ) | The MATCH and INDEX function combination is more powerful to use then VLOOKUP as this combination is capable of looking in any column or row of the table to lock on to and return values. The first MATCH locks on to the Y position relative to the table in the range B11 to B14 which is 3. The second MATCH function locks on to the Quantity header position relative to the table in range A11 to C11 which is 3. The INDEX function returns 200. MATCH will either be used in an absolute frame against the worksheet or in a relative frame against some area on a worksheet. It all depends on where you start the MATCH function from. Absolute style frames always start at Column A or Row 1 when designing the range reference that MATCH will use which means the first problem is using an absolute frame |

- MATCH returns the position of the matched value within lookup_array, not the value itself. For example, MATCH("b",{"a","b","c"},0) returns 2, the relative position of "b" within the array {"a","b","c"}. For example, MATCH("Widget1",A1:A10,0), match would return 2 if cell A2 had Widget1 in it.
- Match is not upper and lower case sensitive.
- Match returns an #N/A if it cannot find an answer.
- If match_type is 0 and lookup_value is text, you can use the wildcard characters, question mark (?) and asterisk (*), in lookup_value. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.

Our next public Excel training workshops and live online Excel courses are listed below. For all of the
dates and times, please visit our Training Schedule page
using the link above in the main menu.

Need Help? Please call us at 1.866.924.6244

Excel Training Services

Microsoft Excel Products

EMAGENIT Company Information

Copyright © 2002-2018

EMAGENIT All Rights Reserved