search a text and return the column head

srkreignz

New Member
Joined
Aug 22, 2014
Messages
27
Hi,

I would like to search for a text in a table and return the column head.

Eg: Table A!:C5

[TABLE="width: 500"]
<tbody>[TR]
[TD]Sl No

[/TD]
[TD] Manager[/TD]
[TD]Trainee[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]John[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Steve [/TD]
[TD]Jeffy[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Harry[/TD]
[TD]Johnson[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Johny[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I wud like to search for john(lower case) in say D2 and get Manger in E2.

Tried the formula
=INDEX(A1:C5,1,MATCH("*"&D2&"*",A2:C5,0))
But not working. Please help !!
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
So what specifically should be in E2 given that D2 contains john? Note that MATCH expects a single row or column of data for the lookup array.
 
Upvote 0
Table A!:C5, sheet 1


[TABLE="class: cms_table, width: 500"]
<tbody>[TR]
[TD]Sl No
[/TD]
[TD]Manager[/TD]
[TD]Trainee[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]John[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Steve[/TD]
[TD]Jeffy[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Harry[/TD]
[TD]Johnson[/TD]
[/TR]
[TR]
[TD="bgcolor: #FAFAFA"]4[/TD]
[TD="bgcolor: #FAFAFA"]Johny[/TD]
[/TR]
</tbody>[/TABLE]



in Sheet 2, Cell A1 , when i type john(not case sensitive), i want all the johns (John, johnson and Johny) listed in column B with their respective designations ( Manager,Trainee, Manager) in column C
 
Upvote 0
@andrews,
the output i want in sheet 2 is

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]john[/TD]
[TD]John[/TD]
[TD]Manager[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]Johnson[/TD]
[TD]Trainee[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD]Johny[/TD]
[TD]Manager[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

and thank you for your patience andrews
 
Upvote 0
To keep the formulas short I used a helper column (formulas in F1:H1 copied down):


Excel 2010
ABCDEFGH
1Sl NoManagerTraineejohn1JohnManager
21John3JohnsonTrainee
32SteveJeffy4JohnyManager
43HarryJohnson
54Johny
Sheet1
Cell Formulas
RangeFormula
G1=IF(ISNUMBER(F1),INDEX($B$2:$C$5,F1,MATCH("*"&$E$1&"*",INDEX($B$2:$C$5,F1,0),FALSE)),"")
H1=IF(ISNUMBER(F1),INDEX($B$1:$C$1,MATCH("*"&$E$1&"*",INDEX($B$2:$C$5,F1,0),FALSE)),"")
F1{=IFERROR(SMALL(IF(ISNUMBER(SEARCH("*"&$E$1&"*",$B$2:$C$5)),ROW($B$2:$C$5)-ROW($B$2)+1),ROWS(F$1:F1)),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,225,476
Messages
6,185,199
Members
453,282
Latest member
roger_nz66

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