MATCH

See Also

Returns the relative position of an item in an array that matches a specified value in a specified order. Use MATCH instead of one of the LOOKUP functions when you need the position of an item in a range instead of the item itself.

Syntax

MATCH(lookup_value,lookup_array,match_type)

Lookup_value   is the value you use to find the value you want in a table.

Lookup_array   is a contiguous range of cells containing possible lookup values. Lookup_array must be an array or an array reference.

Match_type   is the number -1, 0, or 1. Match_type specifies how lookup_value matches with values in lookup_array.

Remarks

Example

The example may be easier to understand if you copy it to a blank spreadsheet.

How?

  1. Create a blank spreadsheet.
  2. Select the example in the Help topic.

    Selecting example from Help

    Selecting an example from Help

  3. Press CTRL+C.
  4. In the spreadsheet, select cell A1, and press CTRL+V.
  5. To switch between viewing the formula that returns the result and the result in the cell, select the cell and press F2 and then ENTER, or click Commands and Options on the spreadsheet toolbar, click the Formula tab, and look in the Formula in active cell (active cell) box.
 
Product Count
Bananas 25
Oranges 38
Apples 40
Pears 41
Formula Description (Result)
=MATCH(39,B2:B5,1) Because there is not an exact match, the position of the next lowest value (38) in the range B2:B5 is returned. (2)
=MATCH(41,B2:B5,0) The position of 41 in the range B2:B5. (4)
=MATCH(40,B2:B5,-1) Returns an error because the range B2:B5 is not in descending order. (#N/A)