Return Column header after matching cell value

aton911

New Member
Joined
Jul 24, 2015
Messages
14
Good Afternoon,

I hope you can help as I am trying to return column header after matching cell value. For example when search for "Cat" it should return Col 3

[TABLE="width: 448"]


<colgroup><col width="64" style="width: 48pt;" span="7">
<tbody>[TR]

[TD="width: 64, bgcolor: transparent"]col1[/TD]

[TD="width: 64, bgcolor: transparent"]col2[/TD]

[TD="width: 64, bgcolor: transparent"]col3[/TD]

[TD="width: 64, bgcolor: transparent"]col4[/TD]

[TD="width: 64, bgcolor: transparent"]col5[/TD]

[TD="width: 64, bgcolor: transparent"]col6[/TD]

[TD="width: 64, bgcolor: transparent"]col7[/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"]Test[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"]Test[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"]Test[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"][/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"]Test[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"]Horse[/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"]Test[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"]Horse[/TD]

[/TR]

[TR]

[TD="bgcolor: transparent"]Animal[/TD]

[TD="bgcolor: transparent"]Apple[/TD]

[TD="bgcolor: transparent"]Cat[/TD]

[TD="bgcolor: transparent"]Dog[/TD]

[TD="bgcolor: transparent"]Test[/TD]

[TD="bgcolor: transparent"][/TD]

[TD="bgcolor: transparent"]Horse[/TD]

[/TR]


</tbody>[/TABLE]
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
try this ... use ctrl shift enter ...

=INDEX(A1:G1,MAX(IF(A2:G17=D21,COLUMN(A2:G17)-COLUMN(A1)+1)))
 
Upvote 0
Aton, or if you had headings in the first row / row 1 rather than col1, col 2 ...etc, and assuming your table started in cell A1, and that you wanted to enter your search in the relevant cell in column 8 (or column H), then enter the following formula in cell I2 (i.e. to search the first row of your table assuming it was laid out as I have specified and return the column heading corresponding to the search term entered in H2):

=INDEX($A$1:$G$1,1,MATCH(H2,$A2:$G2,0))

Please let me know if this is unclear. It is important to specify exactly how the table is laid out in order for me to give you the exact formula.

You can then copy this formula down from I2 to the last row in column I in your table. This will give you the column heading corresponding to where your search word appears in each row of the table.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,836
Messages
6,181,250
Members
453,026
Latest member
cknader

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top