LOOKUP (Vector Form)
The LOOKUP function has two syntax forms: vector and array.
A vector is a range of only one row or one column. The vector form of LOOKUP looks in a one-row or one-column range (known as a vector) for a value and returns a value from the same position in a second one-row or one-column range. Use this form of the LOOKUP function when you want to specify the range that contains the values you want to match. The other form of LOOKUP automatically looks in the first column or row.
Syntax 1
Vector form
LOOKUP(lookup_value,lookup_vector,result_vector)
Lookup_value is a value that LOOKUP searches for in the first vector. Lookup_value can be a number, text, a logical value, or a name or reference that refers to a value.
Lookup_vector is a range that contains only one row or one column. The values in lookup_vector can be text, numbers, or logical values.
Important The values in lookup_vector must be placed in ascending order: ...,-2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE; otherwise, LOOKUP may not give the correct value. Uppercase and lowercase text are equivalent.
Result_vector is a range that contains only one row or column. It must be the same size as lookup_vector.
- If LOOKUP can't find the lookup_value, it matches the largest value in lookup_vector that is less than or equal to lookup_value.
- If lookup_value is smaller than the smallest value in lookup_vector, LOOKUP gives the #N/A error value.
Examples
In the preceding worksheet:
LOOKUP(4.91,A2:A7,B2:B7)
equals "orange"
LOOKUP(5.00,A2:A7,B2:B7)
equals "orange"
LOOKUP(7.66,A2:A7,B2:B7)
equals "violet"
LOOKUP(7.66E-14,A2:A7,B2:B7)
equals #N/A, because 7.66E-14 is less than the smallest value in the lookup_vector A2:A7
LOOKUP (Array Form)
The LOOKUP function has two syntax forms: vector and array.
The array form of LOOKUP looks in the first row or column of an array for the specified value and returns a value from the same position in the last row or column of the array. Use this form of LOOKUP when the values you want to match are in the first row or column of the array. Use the other form of LOOKUP when you want to specify the location of the column or row.
Tip In general, it's best to use the HLOOKUP or VLOOKUP function instead of the array form of LOOKUP. This form of LOOKUP is provided for compatibility with other spreadsheet programs.
Syntax 2
Array form
LOOKUP(lookup_value,array)
Lookup_value is a value that LOOKUP searches for in an array. Lookup_value can be a number, text, a logical value, or a name or reference that refers to a value.
- If LOOKUP can't find the lookup_value, it uses the largest value in the array that is less than or equal to lookup_value.
- If lookup_value is smaller than the smallest value in the first row or column (depending on the array dimensions), LOOKUP returns the #N/A error value.
Array is a range of cells that contains text, numbers, or logical values that you want to compare with lookup_value.
The array form of LOOKUP is very similar to the HLOOKUP and VLOOKUP functions. The difference is that HLOOKUP searches for lookup_value in the first row, VLOOKUP searches in the first column, and LOOKUP searches according to the dimensions of array.
- If array covers an area that is wider than it is tall (more columns than rows), LOOKUP searches for lookup_value in the first row.
- If array is square or is taller than it is wide (more rows than columns), LOOKUP searches in the first column.
- With HLOOKUP and VLOOKUP, you can index down or across, but LOOKUP always selects the last value in the row or column.
Important The values must be placed in ascending order: ...,-2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE; otherwise, LOOKUP may not give the correct value. Uppercase and lowercase text are equivalent.
Examples
LOOKUP("C",{"a","b","c","d";1,2,3,4})
equals 3
LOOKUP("bump",{"a",1;"b",2;"c",3})
equals 2