# E9 | moonshotai/kimi-k3 | run 2

## 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

Use `VLOOKUP` for broad compatibility, or `XLOOKUP` in modern Excel/Microsoft 365.

**VLOOKUP (Excel and Google Sheets)**

```excel
=VLOOKUP(D2, A:B, 2, FALSE)
```

**XLOOKUP (Excel 2021 / Microsoft 365)**

```excel
=XLOOKUP(D2, A:A, B:B, "Not found")
```

## How It Works

**VLOOKUP** searches column A for the value in D2 and returns the value from the 2nd column of the range `A:B` (column B). The `FALSE` argument forces an exact match — without it, you'd need sorted data and risk wrong results.

**XLOOKUP** is cleaner: look up D2 in column A, return the corresponding value from column B, and show "Not found" if there's no match (VLOOKUP returns `#N/A` instead).

## Quick Comparison

| Formula | Compatibility | Handles missing values | Looks left/right |
|---|---|---|---|
| `VLOOKUP` | All versions | No (`#N/A` error) | Right only |
| `XLOOKUP` | Excel 2021+ | Yes (custom message) | Both directions |
| `INDEX/MATCH` | All versions | No | Both directions |

For details, see the [XLOOKUP documentation](https://support.microsoft.com/en-us/office/xlookup-function-b7fd680e-6d10-43e6-84f9-88eae8bf5929) or [VLOOKUP documentation](https://support.microsoft.com/en-us/office/vlookup-function-0bbc8083-26fe-4963-8ab8-93a18ad188a1).

Do you need the formula to handle approximate matches or case-insensitive product names?
