MATCH (relative position in a range)

<< Click to Display Table of Contents >>

MATCH (relative position in a range)

Syntax:

MATCH(Crit, Vector [, Mode])

Description:

This returns the relative position of Crit in Vector. If, for example, Crit is the fifth element of Vector, the function returns 5.

Crit is the value for which the search is performed. This can be any kind of value or a cell reference.

Vector is the cell range or array to be evaluated. This can contain either text strings, numbers or logical values. Vector must be a vector, which is an array or a cell range of either only one row or one column.

Mode specifies the type of search to be performed:

1 or omitted: Find the largest value that is equal to or smaller than Crit. Important: In this mode, the elements in Vector have to be sorted in ascending order. Otherwise, the function may return incorrect results.

0: Find the first value that is equal to Crit. In this mode, the elements in Vector do not have to be in sorted order.

-1: Find the smallest value that is equal to or larger than Crit. Important: In this mode, the elements in Vector have to be sorted in descending order. Otherwise, the function may return incorrect results.

Tip: If you use Mode 0 and you search for a text string, wildcard characters can be used in Crit: A question mark (?) stands for any single character, and an asterisk (*) stands for any sequence of characters.

Example:

MATCH("b", {"a";"b";"c";"d"}, 0) returns 2 because "b" is the second element of the given vector.

See also:

INDEX, LOOKUP, VLOOKUP, HLOOKUP