# How to find the column number of a header in Excel

Match the header name in the header row: `=XMATCH(K1,A1:H1)` returns its column number within the row, here 4.

**Excel:** `=XMATCH(K1,A1:H1)` (Excel 2021, 2024 and Microsoft 365)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F | G | H | I | J | K |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Order | Date | Customer | Region | Rep | Product | Qty | Total |  | Header | Region |
| SO-9101 | 2026-05-04 | Contoso | East | Ana | Desk lamp | 4 | 159.96 |  | Column number |  |
| SO-9102 | 2026-05-04 | Fabrikam | West | Ben | Office chair | 2 | 498 |  |  |  |
| SO-9103 | 2026-05-05 | Northwind | North | Cara | Webcam | 6 | 354 |  |  |  |

Formula in K2: `=XMATCH(K1,A1:H1)`

Result: 4

## How it works

XMATCH searches the header row for the name and returns its position: Region is the 4th header. Because the range starts in column A, the position is also the sheet column number. It is the number VLOOKUP and INDEX need when you want a column by name.

## Other ways

- `=MATCH(K1,A1:H1,0)`: Works in every version; the 0 asks for an exact match.

## Common mistakes

- The number is counted from the first cell of the range. With `C1:H1`, Region would be 2.
- A header with a trailing space doesn't match. Use `TRIM(A1:H1)` inside XMATCH if headers come from imports.

## Questions

**How do I get the column letter?**

Turn the number into an address and strip the row: `=SUBSTITUTE(ADDRESS(1,XMATCH(K1,A1:H1),4),"1","")`.

**How do I use it to return the whole column?**

Give it to INDEX: `=INDEX(A2:H4,0,XMATCH(K1,A1:H1))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/column-number-of-header
