INSPAN Function

Returns True for the position of all values between and including two search values, otherwise False.

INSPAN is a multi-threaded non-volatile dynamic array function.

 

INSPAN Syntax

INSPAN(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. This value is included in the results.

If From_Value does not exist in or is beyond  Range_Array the next nearest value to To_Value 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. This value is included in the results.

If From_Value does not exist in or is beyond Range_Array the next nearest value to From_Value 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).

 

Span Function Examples