# XMATCH formula generator

> Describe what you need and get a XMATCH formula for Excel and Google Sheets, run on real data before you copy it. Plus 6 tested XMATCH examples.

Source: https://spreadsheetpractice.com/tools/formula-generator/xmatch · Updated October 29, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

XMATCH is the modern MATCH: it returns the position of a value in a list, but it defaults to an exact match, can search from the bottom up, and handles wildcards and next-larger or next-smaller matches without sorted data.

Describe the task at [XMATCH formula generator](https://spreadsheetpractice.com/tools/formula-generator/xmatch) and get a XMATCH formula for Excel and Google Sheets, tested on real data.

## Tested XMATCH examples

### Find the column number of a header

`=XMATCH(K1,A1:H1)`

Excel. Result on the sample sheet: 4. [See it and try it](https://spreadsheetpractice.com/formulas/column-number-of-header)

### Find the position of the largest value

`=XMATCH(MAX(B2:B13),B2:B13)`

Excel. Result on the sample sheet: 11. [See it and try it](https://spreadsheetpractice.com/formulas/position-of-largest-value)

### Return columns by header name

`=CHOOSECOLS(A2:F7,XMATCH(H1:I1,A1:F1))`

Excel. Result on the sample sheet: 6 rows (H2:I7). [See it and try it](https://spreadsheetpractice.com/formulas/return-columns-by-header-name)

### Sort by a custom order with a formula

`=SORTBY(A2:C10,XMATCH(B2:B10,F2:F4))`

Excel. Result on the sample sheet: 9 rows (H2:J10). [See it and try it](https://spreadsheetpractice.com/formulas/sort-by-a-custom-order)

### Find the first blank cell in a column

`=XLOOKUP(TRUE,B2:B9="",A2:A9,"Full")`

Excel. Result on the sample sheet: Tue 8 AM. [See it and try it](https://spreadsheetpractice.com/formulas/first-blank-cell-in-column)

### Sum until the first blank cell

`=SUM(TAKE(B2:B9,XMATCH(TRUE,B2:B9="")-1))`

Excel. Result on the sample sheet: $6,005. [See it and try it](https://spreadsheetpractice.com/formulas/sum-until-the-first-blank-cell)

## Questions

### What does the XMATCH formula generator do?

You describe the task in plain English, and it writes the formula, using XMATCH where that's the right tool, for your table or a sample one. The formula is run in our engine in Excel and Google Sheets mode before you see it, so you get its result, not just a guess.

### What does XMATCH do?

XMATCH is the modern MATCH: it returns the position of a value in a list, but it defaults to an exact match, can search from the bottom up, and handles wildcards and next-larger or next-smaller matches without sorted data.

### Can I learn to write XMATCH formulas myself?

Yes. Each example below opens a page where you try the formula in a live grid and it's checked as you go, and the XMATCH function page has a practice exercise.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
