# E9 | deepseek/deepseek-v4-pro | run 1

## Prompt

Write a spreadsheet formula that looks up the price of the product named in cell D2 from a table in columns A (names) and B (prices).

## Response

To look up a price from a product name in cell D2, use an exact‑match lookup against columns A (names) and B (prices). The simplest formula is `=VLOOKUP(D2, A:B, 2, FALSE)` – it searches column A for the value in D2 and returns the corresponding value from column B.

## Recommended formulas

**VLOOKUP (works in Excel and Google Sheets)**
Place this in the cell where you want the price to appear:
```excel
=VLOOKUP(D2, A:B, 2, FALSE)
```
- `D2` is the product name you’re looking for.
- `A:B` means the lookup table spans columns A and B.
- `2` tells the function to return the value from the second column (prices).
- `FALSE` forces an exact match. Without it, the function may return an approximate match, which is rarely desired for product names.

**XLOOKUP (Excel 365, Excel 2021, and Excel for the web only)**
A more flexible, modern alternative:
```excel
=XLOOKUP(D2, A:A, B:B)
```
- Searches the entire column A for the product and returns the corresponding price from column B. Unlike VLOOKUP, it doesn’t require a column index number.

## Adding error handling

If the product in D2 isn’t found, the formulas above return an error (#N/A or #VALUE!). To show a custom message instead, wrap them with `IFERROR`:

*VLOOKUP with error handling*
```excel
=IFERROR(VLOOKUP(D2, A:B, 2, FALSE), "Not found")
```

*XLOOKUP with error handling*
```excel
=XLOOKUP(D2, A:A, B:B, "Not found")
```
(XLOOKUP has a built‑in `[if_not_found]` argument, so you don’t need a separate `IFERROR`.)

## Important notes
- The lookup column (A) must contain the product name exactly as it appears in D2 – no extra spaces or case differences. If needed, use `TRIM` and `UPPER`/`LOWER` to normalise both values.
- VLOOKUP always searches the leftmost column of the range; the price column must be to the right of it. XLOOKUP does not have this limitation.

Would you like assistance handling partial matches or looking up multiple products at once?
