Find the column number of a header
=XMATCH(K1,A1:H1)Excel · result on the sample sheet: 4
Describe what you need and get a working XMATCH formula for Excel and Google Sheets, tested on real data before you copy it. 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.
Each formula below was calculated on its own sample sheet. Open one to see the sheet, why it works, and to try it yourself.
=XMATCH(K1,A1:H1)Excel · result on the sample sheet: 4
=XMATCH(MAX(B2:B13),B2:B13)Excel · result on the sample sheet: 11
=CHOOSECOLS(A2:F7,XMATCH(H1:I1,A1:F1))Excel · result on the sample sheet: 6 rows (H2:I7)
=SORTBY(A2:C10,XMATCH(B2:B10,F2:F4))Excel · result on the sample sheet: 9 rows (H2:J10)
=XLOOKUP(TRUE,B2:B9="",A2:A9,"Full")Excel · result on the sample sheet: Tue 8 AM
=SUM(TAKE(B2:B9,XMATCH(TRUE,B2:B9="")-1))Excel · result on the sample sheet: $6,005
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.
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.
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.