Partial match in table = return column header

tj2419

New Member
Joined
Jun 21, 2013
Messages
15
I am trying to create a fomula in K2 to search for the value in L2 within the range A1:I100 and if it finds a partial match to return the column heading.

E.g. in this scenario it searches for "7s/DT4" finds a match in B2 and returns B1 e.g. Friday 9th Sep: Period 1

I've tried using INDEX and MATCH formulas with wildcards but just don't seem to be able to get it to work. Any one have any advice?

1659605778404.png
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
did you put wildcards on both sides of the cell reference?
Book1
ABCDEFGHIJKL
1staffFriday 9th sep: period 1Friday 9th sep: period 2Friday 9th sep: breakFriday 9th sep: period 3Friday 9th sep: lunch 1Friday 9th sep: lunch 2Friday 9th sep: period 4Friday 9th sep: period 5search key
2mr smithyear 7: 7s/DT4 (2022/2023)year 11: sw/Ch5 (2022/2023)year 7: willow 7a (2022/2023)year 10: 10a/ch7 (2022/2023)Friday 9th sep: period 17s/DT4
Sheet1
Cell Formulas
RangeFormula
K2K2=INDEX($B$1:$I$1,MATCH("*"&$L$2&"*",B2:I2,0))
 
Upvote 0
did you put wildcards on both sides of the cell reference?
Book1
ABCDEFGHIJKL
1staffFriday 9th sep: period 1Friday 9th sep: period 2Friday 9th sep: breakFriday 9th sep: period 3Friday 9th sep: lunch 1Friday 9th sep: lunch 2Friday 9th sep: period 4Friday 9th sep: period 5search key
2mr smithyear 7: 7s/DT4 (2022/2023)year 11: sw/Ch5 (2022/2023)year 7: willow 7a (2022/2023)year 10: 10a/ch7 (2022/2023)Friday 9th sep: period 17s/DT4
Sheet1
Cell Formulas
RangeFormula
K2K2=INDEX($B$1:$I$1,MATCH("*"&$L$2&"*",B2:I2,0))
Thanks @ExceLoki I did but looks like not correctly. The formula appears to work for that one row now but is there a way it can check a few rows of data?

I tried changing it to =INDEX($B$1:$I$1,MATCH("*"&$L$2&"*",B2:I20,0)) but it seems to break the formula.

Thanks again for your help.
 
Upvote 0
you should be able to drag the formula down into the cells below.
what you have it doing there is searching not row by row, but the entire range to return to the one cell k2.
also are you wanting each row to look for the same search key?
Cell Formulas
RangeFormula
A1:A15A1=INDEX($B$1:$I$1,MATCH("*"&$L$2&"*",B2:I2,0))
 
Upvote 0
There will be about 10 search keys in total but they need to search the entire table rather than a specific row as the value could appear in any of the columns or rows between B2:I10.
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,537
Members
449,088
Latest member
RandomExceller01

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