MATCH (relative position in a range)

<< Click to Display Table of Contents >>

MATCH (relative position in a range)

Syntax:

MATCH(Crit, Vector [, Mode])

Description:

Returns the relative position of Crit in Vector. For example, if Crit is the third element of Vector, the function returns 3.

Crit is the value to be searched for. 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 just 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, erroneous results might be returned.

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, erroneous results might be returned.

Tipp: 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, 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