ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Lookups
  3. Return the Column Header for a Value in Excel

Return the Column Header for a Value in Excel

By ExcelReady Team·Updated November 2, 2026·7 min read

The short answer

To return the column header for a value, look across the row and bring back the header from row 1: =INDEX($B$1:$E$1,MATCH(MAX(B2:E2),B2:E2,0)) returns the header of the highest number in row 2. In Excel 2021 or Microsoft 365, =XLOOKUP(MAX(B2:E2),B2:E2,$B$1:$E$1) does the same. Replace MAX with any value to find its header.

Key takeaways

  • Search across the row with MATCH, then use INDEX on the header row to return the name at that position.
  • Lock the header row with $ signs so you can fill the formula down for every row.
  • XLOOKUP does it in one function: what to find, the row to search, the header row to return.
  • MATCH and XLOOKUP return the first match only, so ties give the leftmost header.
  • To list every matching header, use TEXTJOIN with FILTER in Excel 2021 or Microsoft 365.
On this page+
  1. How to return the column header with INDEX and MATCH
  2. How to find the header of the highest value
  3. How to return the column header with XLOOKUP
  4. How to pick the row by name
  5. How to list every matching header
  6. How to find the header of a value anywhere in the grid
  7. Why is the header lookup wrong or #N/A?
  8. Practise it

To return the column header in Excel for a value, you search across a row to find where the value sits, then bring back the header from the same position in row 1. INDEX with MATCH does this in every version of Excel, and XLOOKUP does it in one function in Excel 2021 and Microsoft 365. This guide shows how to find the header of the highest value, of a specific value, and of every value that meets a condition. It is for anyone who needs to answer "which month?" or "which quarter?" from a grid of numbers.

All examples use this quarterly sales grid:

ABCDE
1RepQ1Q2Q3Q4
2Dana410520380495
3Raj610450700530
4Mia300340290360

How to return the column header with INDEX and MATCH#

The idea is a horizontal lookup in reverse. You know a value in the data, and you want the label above it. Two functions share the work:

  • MATCH searches a row and returns the position of the value: 1 for the first cell, 2 for the second, and so on.
  • INDEX takes a range and a position and returns what sits there.

To find which quarter Dana sold 520 in:

Excel formula
=INDEX($B$1:$E$1,MATCH(520,B2:E2,0))

MATCH finds 520 in the 2nd cell of B2:E2, so it returns 2. INDEX returns the 2nd cell of B1:E1, which is Q2. The 0 in MATCH means exact match. Without it, MATCH assumes the row is sorted and can return the wrong position.

The key rule: the header row and the search row must start in the same column and be the same width. B1:E1 and B2:E2 both run from B to E, so position 2 means column C in both. The INDEX function guide and the MATCH function guide explain each part, and the article on the MATCH function covers its match types.

How to find the header of the highest value#

Replace the fixed value with MAX to find the best column in each row:

Excel formula
=INDEX($B$1:$E$1,MATCH(MAX(B2:E2),B2:E2,0))

Type it in F2 and fill down to F4 (Windows: Ctrl+D; Mac: ⌘D):

RepBest quarterWhy
DanaQ2520 is her highest
RajQ3700 is his highest
MiaQ4360 is her highest

The $ signs lock the header row, so every row still returns a name from B1:E1. The search row has no $, so it moves down with the formula. For the weakest column, use MIN instead of MAX: =INDEX($B$1:$E$1,MATCH(MIN(B4:E4),B4:E4,0)) returns Q3 for Mia (290). Practise INDEX and MATCH in a live spreadsheet to get the pattern into your fingers.

How to return the column header with XLOOKUP#

XLOOKUP needs only one function. You give it the value to find, the row to search and the row to return from:

Excel formula
=XLOOKUP(MAX(B3:E3),B3:E3,$B$1:$E$1)

The result is Q3, the quarter of Raj's 700. XLOOKUP looks across a row just as easily as down a column, and it defaults to an exact match. Add a fourth argument for a message when nothing is found:

Excel formula
=XLOOKUP(999,B3:E3,$B$1:$E$1,"Not found")

This returns Not found instead of #N/A. XLOOKUP needs Excel 2021 or Microsoft 365. See the XLOOKUP function guide and practise XLOOKUP.

How to pick the row by name#

Sometimes you know the rep's name, not their row. Find the row first, then find the header inside it. With XLOOKUP, the inner XLOOKUP returns Mia's whole row of numbers:

Excel formula
=XLOOKUP(MAX(XLOOKUP("Mia",A2:A4,B2:E4)),XLOOKUP("Mia",A2:A4,B2:E4),B1:E1)

The result is Q4. With INDEX and MATCH, INDEX with a column number of 0 returns the whole row:

Excel formula
=INDEX(B1:E1,MATCH(MAX(INDEX(B2:E4,MATCH("Mia",A2:A4,0),0)),INDEX(B2:E4,MATCH("Mia",A2:A4,0),0),0))

It's long, but every piece is a pattern you already know. Put "Mia" in a cell, such as H1, and point the formula at it so you can change the name. The guides to two-way lookups and INDEX MATCH MATCH go the other direction: from a row name and a column header to the value.

How to list every matching header#

MATCH and XLOOKUP stop at the first match. To list all headers that meet a condition, combine FILTER and TEXTJOIN:

Excel formula
=TEXTJOIN(", ",TRUE,FILTER(B1:E1,B3:E3>500))

FILTER keeps the headers where Raj's sales are over 500, and TEXTJOIN joins them with a comma. The result is Q1, Q3, Q4. This needs Excel 2021 or Microsoft 365.

The same idea handles ties. If two quarters share the highest value, =TEXTJOIN(", ",TRUE,FILTER(B1:E1,B2:E2=MAX(B2:E2))) lists both instead of only the first.

How to find the header of a value anywhere in the grid#

If you don't know which row the value is in, SUMPRODUCT can find its column position across the whole grid:

Excel formula
=INDEX(B1:E1,SUMPRODUCT((B2:E4=700)*(COLUMN(B2:E4)-COLUMN(B1)+1)))

The test marks the cell that holds 700 with a 1. COLUMN(B2:E4)-COLUMN(B1)+1 numbers the columns 1 to 4, so SUMPRODUCT returns 3, and INDEX returns Q3. This only works when the value appears exactly once. If it appears twice, the positions are added together and the answer is wrong. If it doesn't appear, the result is 0, and INDEX with a column number of 0 returns the whole header row instead of one header.

Why is the header lookup wrong or #N/A?#

Most errors come from a few causes:

  1. The value isn't in the row. MATCH and XLOOKUP return #N/A. Check spelling, and check for numbers stored as text.
  2. The rows don't line up. If the header row is A1:E1 but the search row is B2:E2, every result is shifted one column. Start both in the same column.
  3. Missing 0 in MATCH. Without the 0, MATCH does an approximate match and can return a nearby column.
  4. Missing $ on the header row. When you fill down, B1:E1 becomes B2:E2, and the formula returns numbers instead of headers.
  5. Ties. Only the first header from the left is returned. Use the FILTER method if ties matter.

For a newer alternative to MATCH that can also search from the right, see the XMATCH function. The guide to INDEX MATCH covers the vertical version.

Practise it#

Returning a header is a lookup turned sideways, and it comes up in reporting tasks and job tests. Practise INDEX and MATCH in a live spreadsheet, then practise XLOOKUP: you type each formula and ExcelReady checks it instantly. Start with Raj's best quarter in the exercise on this page.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Which quarter was Raj's best? Click F3 and use INDEX, MATCH and MAX to return the header from B1:E1 for the highest value in B3:E3.

fx
ABCDEFG
1
Rep
Q1
Q2
Q3
Q4
Best quarter
2
Dana
410
520
380
495
3
Raj
610
450
700
530
4
Mia
300
340
290
360
5
6
7

Tip: MAX(B3:E3) finds the best value. MATCH(...,B3:E3,0) finds its position. INDEX(B1:E1, position) returns the header.

Practise this in a lesson

LessonINDEX and MATCHCombine INDEX and MATCH to look up in any direction, including returning a column to the left of the one you search.LessonXLOOKUPLook up in any direction with XLOOKUP and show a friendly message when nothing matches.Function guideINDEXLearn the Excel INDEX function: return a value by row and column position, build two-way lookups with MATCH, and practice live.Function guideMATCHLearn how Excel's MATCH finds the position of a value, why the 0 matters, and how it powers INDEX/MATCH. Includes a live exercise.Function guideXLOOKUPXLOOKUP explained with real examples: exact matches, looking left and custom not-found messages, plus a live exercise to try now.

Frequently asked questions

How do I return the column header of the max value in Excel?

+

Use =INDEX($B$1:$E$1,MATCH(MAX(B2:E2),B2:E2,0)). MAX finds the highest number in the row, MATCH finds its position, and INDEX returns the header at that position.

How do I find which column a value is in?

+

Use MATCH across the row: =MATCH(450,B3:E3,0) returns the position, such as 2. Wrap it in INDEX with the header row to get the header name instead of the number.

Can XLOOKUP return a column header?

+

Yes. Search the data row and return the header row: =XLOOKUP(G2,B2:E2,B1:E1). Both ranges must be the same width. XLOOKUP needs Excel 2021 or Microsoft 365.

What if two columns have the same highest value?

+

MATCH and XLOOKUP return the first match from the left, so you get only one header. To list all of them, use =TEXTJOIN(", ",TRUE,FILTER(B1:E1,B2:E2=MAX(B2:E2))).

Why does my header lookup return #N/A?

+

The value wasn't found in the row. Check that the number isn't stored as text, that the lookup row and header row are the same width, and that you used 0 for an exact match in MATCH.

Sources

  • INDEX function - Microsoft Support
  • MATCH function - Microsoft Support
  • XLOOKUP function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. How to return the column header with INDEX and MATCH
  2. How to find the header of the highest value
  3. How to return the column header with XLOOKUP
  4. How to pick the row by name
  5. How to list every matching header
  6. How to find the header of a value anywhere in the grid
  7. Why is the header lookup wrong or #N/A?
  8. Practise it

Keep reading

Lookups· 6 min read

Two-Way Lookup in Excel (Row and Column)

A two-way lookup finds the value where a row and a column meet, like units sold for one product in one month. Use INDEX with two MATCHes: =INDEX(B2:E6,MATCH(H1,A2:A6,0),MATCH(H2,B1:E1,0)). The first MATCH finds the row, the second finds the column, and INDEX returns the cell where they cross.

Lookups· 6 min read

INDEX MATCH MATCH: Two-Way Lookups Explained

INDEX MATCH MATCH is a two-way lookup: =INDEX(B2:E6,MATCH(H1,A2:A6,0),MATCH(H2,B1:E1,0)). The first MATCH finds the row of the item in H1, the second finds the column of the heading in H2, and INDEX returns the value where they meet. It works in every Excel version and doesn't break when you insert columns.

Lookups· 6 min read

The MATCH Function in Excel

MATCH finds a value in a row or column and returns its position, not the value itself. =MATCH("Marco",B2:B7,0) returns 4 if Marco is the 4th name in B2:B7. Always use 0 as the third argument for an exact match. MATCH is most useful inside INDEX, as =INDEX(A2:A7,MATCH(F2,B2:B7,0)), to look up in any direction.

More on lookups

  • Tax Bracket and Tier Lookups in Excel
  • VLOOKUP in Excel: Step-by-Step for Beginners
  • VLOOKUP From Another Workbook in Excel
  • VLOOKUP Approximate Match for Tiers and Bands
  • VLOOKUP Return Blank Instead of 0
  • VLOOKUP Column Index Number Explained
All lookups articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free