How to Use the LOOKUP Function in Google Sheets | Search for Approximate Matches in a Range
How to Use the LOOKUP Function
The LOOKUP function searches a single-row or single-column range that is sorted in ascending order and returns the value at the same position in a separate result range. It is primarily used for approximate match lookups, such as assigning grades or tiered rates.
Syntax
=LOOKUP(search_key, search_range, [result_range])
- search_key: The value (number, text, or cell reference) to search for (required).
- search_range: A single-row or single-column cell range to search (required). It must be sorted in ascending order.
- result_range: A single-row or single-column cell range from which to return a value (optional). It must have the same number of elements as
search_range; if omitted, the matching value is returned fromsearch_rangeitself.
Example Using a Table
Here is an example of determining a grade based on a test score (85) using the “Evaluation Criteria Table (A2:B5)” below.
| Row | Column A (Threshold Score) | Column B (Grade) |
|---|---|---|
| 1 | Threshold Score | Grade |
| 2 | 0 | D |
| 3 | 60 | C |
| 4 | 80 | B |
| 5 | 90 | A |
- Formula:
=LOOKUP(85, A2:A5, B2:B5) - Result:
B(matches80, the largest value less than or equal to85, and returns the corresponding value from Column B)
Common Errors and Notes
- Incorrect Results When Not Sorted Ascending:
LOOKUPassumes the data is sorted in ascending order. If the order is unsorted, it will return a value from an entirely wrong row. - Searching Below the Minimum Value (
#N/A): If thesearch_keyis smaller than the first (minimum) value insearch_range, no match is found and a#N/Aerror occurs. Make sure the first entry in your criteria table is a sufficiently small value such as0. - Caution with the 2-Argument Array Form: There is an older syntax that omits
result_rangeand passes a 2D array, whereLOOKUPdecides whether to search by row or column based on the shape of the range. Using the 3-argument form (orXLOOKUP) is safer and clearer.
Frequently Asked Questions
Q. What is the most important prerequisite for using the LOOKUP function?
A. The data in the search range must be sorted in ascending order (smallest to largest, or A to Z). If it is not sorted in ascending order, binary search will fail and return incorrect results or errors.
Q. Should I use LOOKUP when I need an exact match?
A. No. Because LOOKUP is designed for approximate matching (matching the largest value less than or equal to the search key), you should use XLOOKUP or VLOOKUP with the fourth argument set to FALSE for reliable exact matches.