Sub topic 11
Looking Up a Whole Column of Keys
Assume you know how to enter formulas, use cell and range references, lock ranges with $, and reference another sheet. In earlier examples, one lookup formula handled one key. When a sheet contains many keys, you can apply the lookup to a range and return all results at once.
The repeated-lookup problem
Suppose the Orders sheet has product keys in A2:A20. The product catalog is on the Products sheet:
| Product key | Product name | Price |
|---|---|---|
| P-101 | Small Widget | 12.50 |
| P-102 | Large Widget | 18.00 |
| P-103 | Cable Set | 7.25 |
You want the product price beside every order key. Copying a formula down works, but it creates many separate formulas. A range lookup can calculate the whole result column from one formula.
Applying VLOOKUP to many keys
ARRAYFORMULA tells Google Sheets to process an array, or a range of values, instead of only one value. Pass the entire key range as the first argument to VLOOKUP:
=ARRAYFORMULA(VLOOKUP(A2:A20, Products!A2:C100, 3, FALSE))For each key in A2:A20, this formula searches the first column of Products!A2:C100. It returns the value from column 3 of that range, which is the price. FALSE forces exact matching.
The results fill downward from the formula cell. Put the formula in B2, and the first result appears in B2, the second in B3, and so on. The cells below B2 must be empty. Existing values can cause an array result error because Sheets cannot overwrite them.
Use absolute references when you plan to copy or reuse the formula with a different starting cell:
=ARRAYFORMULA(VLOOKUP(A2:A20, Products!$A$2:$C$100, 3, FALSE))The $ characters keep the catalog range fixed. The lookup range A2:A20 remains relative to the formula's intended input.
Handling missing keys
If a key is absent from the catalog, VLOOKUP returns #N/A. Wrap the lookup in IFNA to return a useful label:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A20, Products!$A$2:$C$100, 3, FALSE), "Not found"))This also applies the replacement to every missing key in the input range. Empty input cells may produce "Not found" as well. If you want blank input rows to stay blank, test the key first:
=ARRAYFORMULA(IF(A2:A20="", "", IFNA(VLOOKUP(A2:A20, Products!$A$2:$C$100, 3, FALSE), "Not found")))The outer IF prevents a lookup for empty rows.
Using XLOOKUP for a whole range
XLOOKUP separates the lookup range from the result range, so it does not need a column index:
=XLOOKUP(A2:A20, Products!$A$2:$A$100, Products!$C$2:$C$100, "Not found")It searches each key in A2:A20 and returns the corresponding value from column C. XLOOKUP can return the array directly in Google Sheets. If your sheet or formula context does not spill the results as expected, use one formula per row or test the formula in a small range first.
For a growing list, use open-ended ranges carefully:
=XLOOKUP(A2:A, Products!$A$2:$A, Products!$C$2:$C, "Not found")This can process new keys automatically, but large open-ended ranges may require more calculation than bounded ranges.
Choosing the approach
| Situation | Suitable formula |
|---|---|
| Existing VLOOKUP workflow | `ARRAYFORMULA(VLOOKUP(...))` |
| Separate lookup and result columns | `XLOOKUP(A2:A20, lookup_range, result_range, "Not found")` |
| Missing keys need readable output | Add `"Not found"` or use `IFNA` |
| Input range includes blank rows | Wrap the lookup in `IF` |
Exercise
Write one formula in B2 that looks up every key in A2:A20 against Products!A2:A100 and returns the matching value from Products!C2:C100. Missing keys should display "Not found".
Show answer
=XLOOKUP(A2:A20, Products!$A$2:$A$100, Products!$C$2:$C$100, "Not found")