LocalExcelTool
Get started

Excel LOOKUP function

LOOKUP is the oldest lookup function in Excel. It only does approximate matching (so the vector must be sorted), yet two jobs still belong to it: banding a value into tiers, and the 1/(condition) trick for grabbing the last matching row. For ordinary lookups in a new file, use XLOOKUP — the syntax says what it does.

Lookup & reference · Available in: Excel 97 and every desktop version since

Syntax

LOOKUP(lookup_value, lookup_vector, [result_vector])

What it returns The value in result_vector at the position where lookup_vector matched.

Arguments
lookup_valuerequiredThe value to find.
lookup_vectorrequiredA one-dimensional range, which must be sorted ascending — otherwise the result is unpredictable.
result_vectoroptionalThe one-dimensional range to return from, the same size as lookup_vector.

Examples

The last record that matches

OrderStatus
1001Shipped
1002Pending
1003Shipped
= LOOKUP(2,1/(B2:B4="Shipped"),A2:A4)

→ 1003

1/(condition) turns TRUE into 1 and FALSE into #DIV/0!, giving {1,#DIV/0!,1}. Looking for 2 — which is never found — makes LOOKUP return the position of the last value not exceeding it, so the last 1 wins and A4's 1003 comes back. This is the standard "last match" idiom.

Common mistakes

  • 1.Using LOOKUP for an exact match. It has no match_type argument, so a missing value returns the closest smaller one instead of an error — a silent wrong answer, the hardest kind to find.
  • 2.An unsorted lookup_vector. LOOKUP assumes ascending order and returns something arbitrary when it is not.
  • 3.result_vector a different height from lookup_vector, which shifts every answer.

How to use it

  1. 1.Click the cell where the result should appear.
  2. 2.Type = then the function name, and press Tab to accept it.
  3. 3.Enter each argument separated by commas; ranges can be dragged with the mouse.
  4. 4.Press Enter. Drag the fill handle down if the same formula applies to more rows.

Frequently asked questions

What is the syntax of LOOKUP?

LOOKUP(lookup_value, lookup_vector, [result_vector]). What it returns: The value in result_vector at the position where lookup_vector matched.

Which Excel versions support LOOKUP?

Excel 97 and every desktop version since. It is available in every desktop version unless the note above says otherwise.

Why does LOOKUP return an error instead of a value?

Using LOOKUP for an exact match. It has no match_type argument, so a missing value returns the closest smaller one instead of an error — a silent wrong answer, the hardest kind to find.

Related functions

More in this group

Need to get the data in first?

← All Excel formulas