Search data within table and return the column header

winfs

New Member
Joined
Aug 21, 2018
Messages
2
Hi

I am trying to search a data within a table and return the header of the corresponding column. For example,

[TABLE="width: 192"]
<tbody>[TR]
[TD="width: 64"][/TD]
[TD="class: xl65, width: 64"] A[/TD]
[TD="class: xl65, width: 64"] B[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]Test1[/TD]
[TD="align: right"]Test2[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]17[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]18[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]19[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]20[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]7[/TD]
[TD="align: right"]18[/TD]
[TD="class: xl66"] B[/TD]
[/TR]
</tbody>[/TABLE]
If cell A7 = 18, then cell B7 = Test2
If cell A7 = 15, then cell B7 = Test1

can anyone help to create such formula in cell B7?

thanks,
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Book1
ABC
1Test1Test2
21217
31318
41419
51520
6
718Test2
8
Sheet1


In B7 control+shift+enter, not just enter, and copy across:

=IFERROR(INDEX($A$1:$B$1,SMALL(IF($A$2:$B$5=$A$7,COLUMN($A$1:$B$1)-COLUMN($A$1)+1),COLUMNS($B$1:B$1))),"")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,169
Members
453,021
Latest member
Justyna P

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