MATCH.SPAN Function

Returns an array  containing 2 values giving  the position of two inclusive search values within a single-column or single-row range or array. The returned array will be a 2 value row for a column or a 2 value column for a row.

MATCH.SPAN is a multi-threaded non-volatile dynamic array function.

 

MATCH.SPAN Syntax

MATCH.SPAN(Range_Array,From_Value, To_Value, Match_Mode)

Range_Array (Required)

A single column or row of an array or range to be searched.

From_Value (Required)

The value to be searched for, starting at the top of Range_Array and searching down the rows or across the columns. For duplicated values the first value found is used.

To_Value (Required)

The value to be searched for, starting at the bottom/right of Range_Array and searching up the rows or right-to-left in the columns. For duplicated values the first value found is used.

 

Note: From_Value must always be less than To_Value even when the Range_Array is sorted descending.

Match_Mode (Optional – default 0 unsorted)

0 Unsorted – Linear search method is used

1 Sorted Ascending – very efficient binary search method is used

-1 Sorted Descending – very efficient binary search method is used.

Handling of errors and out of bounds conditions

When Range_Array is sorted (Match_Mode 1 or -1)

Out of Bounds:

From and To values outside the first or last value in Range_Array are treated as the corresponding first or last value, unless both the From and To values are less than the first value or greater than the last value (there is no span so error).

Missing Values:

When From or To values are missing within Range_Array the next closest value within the span is used.

Duplicate Values:

When there are duplicated From and To values within Range_Array the outermost value found is used.

Empty Span:

From and To values that produce an empty span are treated as errors (#N/A).

 

When Range_Array is unsorted (Match_Mode 0)

Out of Bounds:

From and To values outside the first or last value in Range_Array are treated as errors (#N/A).

Missing Values:

Missing From or To values are treated as errors (#N/A)

When there are duplicated From and To values within Range_Array the outermost value found is used.

Empty Span:

From and To values that produce an empty span are treated as errors (#N/A).