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

Sl No

ManagerTrainee
1
John
2
Steve Jeffy
3
HarryJohnson
4Johny

<tbody>
</tbody>


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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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

srkreignz

New Member
Joined
Aug 22, 2014
Messages
27
@andrew what I am trying to do is to list the designation of all johns in the table.
 
Upvote 0

srkreignz

New Member
Joined
Aug 22, 2014
Messages
27
Table A!:C5, sheet 1


Sl No
ManagerTrainee
1John
2SteveJeffy
3HarryJohnson
4Johny

<tbody>
</tbody>



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

srkreignz

New Member
Joined
Aug 22, 2014
Messages
27
@andrews,
the output i want in sheet 2 is

ABC
1johnJohnManager
2JohnsonTrainee
3JohnyManager
4

<tbody>
</tbody>

and thank you for your patience andrews
 
Upvote 0

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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,191,274
Messages
5,985,702
Members
439,975
Latest member
eelyn

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
Top