r/excel • • 6d ago

solved Formula to show header of table

Hi Guys, can you please show how to correct the formula below to show the header of the table (AAA, BBB, CCC), I have tried Index Match and XlookUp but kept getting errors;

13 Upvotes

15 comments sorted by

•

u/AutoModerator 6d ago

/u/Radiant_Arrival_6179 - Your post was submitted successfully.

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

6

u/Chrome_CW 3 6d ago

XLOOKUP is GREAT for most purposes, but here:

XLOOKUP requires lookup_array and return_array to have matching dimensions (same number of rows for vertical lookups, or same number of columns for horizontal lookups), otherwise you'll get a #VALUE! error.

As Kimmy mentions below, INDEX MATCH may be your easiest option here....

Though you could accomplish it with a latest version of EXCEL365 using BYCOL and LAMBDA:

=XLOOKUP(TRUE, BYCOL($A$7:$C$11, LAMBDA(col, OR(col=F7))), $A$6:$C$6)

3

u/Radiant_Arrival_6179 6d ago

Solution Verified

2

u/reputatorbot 6d ago

You have awarded 1 point to Chrome_CW.


I am a bot - please contact the mods with any questions

1

u/Post_Contrer34 6d ago

even a standard INDEX MATCH struggles with a 2D block like $A$7:$C$11 though, since MATCH only accepts a single row or column

2

u/SolverMax 167 6d ago

Perhaps:

=CONCAT(IF($A$7:$C$11=F7,$A$6:$C$6,""))

Or, if more than one heading may be returned:

=TEXTJOIN(",",TRUE,IF($A$7:$C$11=F7,$A$6:$C$6,""))

1

u/Radiant_Arrival_6179 6d ago

Solution Verified

1

u/reputatorbot 6d ago

You have awarded 1 point to SolverMax.


I am a bot - please contact the mods with any questions

3

u/CorndoggerYYC 162 6d ago

=INDEX($A$1:$C$1, XMATCH(TRUE, BYCOL($A$2:$C$6, LAMBDA(c, COUNTIF(c, E2)>0)), 0))

You need to search column by column for the value you're looking for.

3

u/real_barry_houdini 322 4d ago

To get all 5 results with a single "dynamic array formula" use this formula in G7 (with cells below left empty)

=XLOOKUP(F7:F11,TOCOL(A7:C11),TOCOL(IFNA(A6:C6,A7:C11)))

TOCOL function is used to convert both A7:C11 and A6:C6 into single columns of the same size - then you can use a regular XLOOKUP function to lookup all values in F7:F11 - if you want you can use the "if not found" option in XLOOKUP to convert #N/A error to something else.

2

u/kimmykim328 6d ago

I don’t use xlookup, I’m still old school and use index match, but try fixing A6:C11 to A7
I was about to write you an index match formula but it doesn’t work across columns I don’t believe

1

u/Intuin_Rhaabat 6d ago edited 6d ago

Oh, I see, I think you're saying you want to find the number in A5:C11, and return the value that is in row 5 of the column where that number is. Is that right?


Original response which probably isn't helpful:

Your request is a bit confusing. In the image, it looks like you are trying to get a formula to return the two values from columns B & C that relate to your list in column F. This should do that I think:

=xlookup(F7,A6:A11,B6:C11)

The words in your actual request suggest you want to return the headers themselves, which is a bit weird. The formula for that would just be:

=A6:C6

1

u/Decronym 6d ago edited 4d ago

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer LettersMore Letters
BYCOLOffice 365+: Applies a LAMBDA to each column and returns an array of the results
COLUMNReturns the column number of a reference
CONCAT2019+: Combines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments.
COUNTIFCounts the number of cells within a range that meet the given criteria
FILTEROffice 365+: Filters a range of data based on criteria you define
IFSpecifies a logical test to perform
IFNAExcel 2013+: Returns the value you specify if the expression resolves to #N/A, otherwise returns the result of the expression
INDEXUses an index to choose a value from a reference or array
ISNUMBERReturns TRUE if the value is a number
LAMBDAOffice 365+: Use a LAMBDA function to create custom, reusable functions and call them by a friendly name.
MATCHLooks up values in a reference or array
MINReturns the minimum value in a list of arguments
ORReturns TRUE if any argument is TRUE
SUMPRODUCTReturns the sum of the products of corresponding array components
TEXTJOIN2019+: Combines the text from multiple ranges and/or strings, and includes a delimiter you specify between each text value that will be combined. If the delimiter is an empty text string, this function will effectively concatenate the ranges.
TOCOLOffice 365+: Returns the array in a single column
VALUEConverts a text argument to a number
XLOOKUPOffice 365+: Searches a range or an array, and returns an item corresponding to the first match it finds. If a match doesn't exist, then XLOOKUP can return the closest (approximate) match.
XMATCHOffice 365+: Returns the relative position of an item in an array or range of cells.

Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.


Beep-boop, I am a helper bot. Please do not verify me as a solution.
[Thread #49758 for this sub, first seen 28th Nov 2026, 06:44] [FAQ] [Full list] ^[Contact] [Source code]

1

u/DebitsCreditsnReddit 4 6d ago edited 6d ago

Edit: fixed screenshot. 1) Formula text in H25 included ISNUMBER from H16. 2) Color coded formula text. 3) Added an example of FILTER returning 2 headers.

Jumping in with a screenshot that shows my steps / strategies for a function or two that may be new to you.

Basically does the same as u/Chrome_CW though. Theirs is more elegant, mine just isn't case sensitive. Plus, if there's more than one column with a match, it will return multiple column headers.

0

u/Nervous-Toe5784 1 6d ago

If you're on 365, this returns the header(s) of whichever column contains your lookup value (G1 here):

=TEXTJOIN(", ",TRUE,FILTER(Table1[#Headers],BYCOL(Table1,LAMBDA(c,OR(c=G1)))))

If the value can only appear once, this works on older versions too:

=INDEX(Table1[#Headers],SUMPRODUCT((Table1=G1)*(COLUMN(Table1)-MIN(COLUMN(Table1))+1)))