Partial Match in Excel

AHS5050

New Member
Joined
Feb 6, 2022
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I receive raw data from our central system that has over thousands of rows of data each month. I need to clean the data manually to show which company each row belongs to. It a tedious work that takes hours.

I am hoping to be able to search names in a cell/cells with long texts. For example, I search for the words "Mike", "Steve", "Key", "Tim", (A12 to A16) in cells B3 to B9. If Excel finds a match, then puts the corresponding simple Name from B12 to B16, as shown in Column F. For example, I want to search for "Mike" in a cell that contains "Mike Miller Associates PY Adj" or "Reclass for Mike Miller for CY", etc. Please see the screen shot below.

Would you please help in creating a formula (in the yellow column) that will put the Complete Name of each company in the yellow cells based on a Search Key table?

1644279492899.png

Thank you,
Haseeb
 

Attachments

  • 1644278435868.png
    1644278435868.png
    27.2 KB · Views: 9
  • 1644279293970.png
    1644279293970.png
    37.1 KB · Views: 8

Excel Facts

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

Please consider uploading sample using XL2BB (see my signature), or at least in table format, so helpers don't Have to manually type up data.

BTW, your written requirements differs from the requirements in your picture attachments, this is based on your Written description.

Try this:

Book3.xlsx
ABCD
1
2
3Steve abc def ghiSteve Fox Ltd
4Mike abc def ghiMike Miller Associates
5Miss-coding Jasson KeyJasson Key Superstore
6Mike xyz jklMike Miller Associates
7Steve iop wer yuuSteve Fox Ltd
8Nov 2021 Elsa and TimElsa and Tim
9Refund Jasson Key Jasson Key Superstore
10abc Walmart 
11
12
13MikeMike Miller Associates
14SteveSteve Fox Ltd
15KeyJasson Key Superstore
16TimElsa and Tim
Sheet995
Cell Formulas
RangeFormula
D3:D10D3=IFERROR(LOOKUP(2,1/SEARCH(A$13:A$16,B3),B$13:B$16),"")
 
Last edited:
Upvote 0
Thank you jtakw. I appreciate it.

I tried to simplify the question thinking it may not be possible to use Excel for my issue, but your skill proved me wrong. I actually get the raw data with notes in 5 different columns. Each of them could contain the keyword. So if the keyword cannot be found in one column, the formula looks at the next one until it finds the key word. I tried to use your solution and apply it to other columns but failed. I hope I am not being a pain here. Is it possible to expand the formula over 5 columns?

Partial Match.xlsx
ABCDEFG
1
2Note 1Note 2Note 3Note 4Note 5Keys
3Steve abc def ghiSteve Fox Ltd
4Sam abc def ghiMike abc def ghi klabcdefdef ty76 
5Miss-coding Jasson KeyJasson Key Superstore
6Tom xyz jklklpMike xyz jkl56ip56ip 90sadf 
7Stevenson iop wer yuuAlex rt5Steve iop wer yuuSteve Fox Ltd
8Nov 2021 Elsa and AndyNov 2021 Elsa and Tim 
9Refund Jasson KeyJasson Key Superstore
10abc Walmart 
11
12
13
14NameComplete Name
15MikeMike Miller Associates
16SteveSteve Fox Ltd
17KeyJasson Key Superstore
18TimElsa and Tim
SAP 2021 (2)
Cell Formulas
RangeFormula
G3:G10G3=IFERROR(LOOKUP(2,1/SEARCH('SAP 2021 (2)'!A$15:A$18,B3),'SAP 2021 (2)'!B$15:B$18),"")
 
Upvote 0
Welcome to the MrExcel board!

.. and thanks for using XL2BB this time.

Firstly, with your original sample, the formula suggested by @jtakw could possibly return incorrect results - see cell D10 below.

AHS5050.xlsm
ABCD
1
2
3Steve abc def ghiSteve Fox Ltd
4Mike abc def ghiMike Miller Associates
5Miss-coding Jasson KeyJasson Key Superstore
6Mike xyz jklMike Miller Associates
7Steve iop wer yuuSteve Fox Ltd
8Nov 2021 Elsa and TimElsa and Tim
9Refund Jasson Key Jasson Key Superstore
10Refund from Stimson LtdElsa and Tim
11
12
13MikeMike Miller Associates
14SteveSteve Fox Ltd
15KeyJasson Key Superstore
16TimElsa and Tim
Sheet1
Cell Formulas
RangeFormula
D3:D10D3=IFERROR(LOOKUP(2,1/SEARCH(A$13:A$16,B3),B$13:B$16),"")


Adjusting @jtakw's formula to stop that and allowing for the multiple columns, try this.

AHS5050.xlsm
ABCDEFG
1
2Note 1Note 2Note 3Note 4Note 5Keys
3Steve abc def ghiSteve Fox Ltd
4Sam abc def ghiMike abc def ghi klabcdefdef ty76Mike Miller Associates
5Miss-coding Jasson KeyJasson Key Superstore
6Tom xyz jklklpMike xyz jkl56ip56ip 90sadfMike Miller Associates
7Stevenson iop wer yuuAlex rt5Steve iop wer yuuSteve Fox Ltd
8Nov 2021 Elsa and AndyNov 2021 Elsa and TimElsa and Tim
9Refund Jasson KeyJasson Key Superstore
10abc Walmart 
11
12
13
14NameComplete Name
15MikeMike Miller Associates
16SteveSteve Fox Ltd
17KeyJasson Key Superstore
18TimElsa and Tim
Sheet2
Cell Formulas
RangeFormula
G3:G10G3=IFERROR(LOOKUP(2,1/SEARCH(" "&A$15:A$18&" "," "&TEXTJOIN(" ",1,B3:F3)&" "),B$15:B$18),"")


One further point: It is a bad idea to use the sheet name of the sheet that the formula is in like you have in your formula in post #3
That is, using the following formula in sheet 'SAP 2021 (2)' can lead to problems.
=IFERROR(LOOKUP(2,1/SEARCH('SAP 2021 (2)'!A$15:A$18,B3),'SAP 2021 (2)'!B$15:B$18),"")
 
Upvote 0
Solution
Also, if there could be any sort of overlap with the short names, like in cells A5 & A18 below, the previous formula could still return dubious results as shown in G4 below.
An alternative is shown in column H that for a situation like that would list all possible matches and you could AutoFilter that columns for "contains" "/" to manually enter the correct results.

AHS5050.xlsm
ABCDEFGH
1
2Note 1Note 2Note 3Note 4Note 5KeysKeys
3Steve abc def ghiSteve Fox LtdSteve Fox Ltd
4Sam abc def ghiMike Miller abcabcdefdef ty76Ken & MikeMike Miller Associates / Ken & Mike
5Miss-coding Jasson KeyJasson Key SuperstoreJasson Key Superstore
6Tom xyz jklklpMike xyz jkl56ip56ip 90sadfKen & MikeKen & Mike
7Stevenson iop wer yuuAlex rt5Steve iop wer yuuSteve Fox LtdSteve Fox Ltd
8Nov 2021 Elsa and AndyNov 2021 Elsa and TimElsa and TimElsa and Tim
9Refund Jasson KeyJasson Key SuperstoreJasson Key Superstore
10abc Walmart  
11
12
13
14NameComplete Name
15Mike MillerMike Miller Associates
16SteveSteve Fox Ltd
17KeyJasson Key Superstore
18MikeKen & Mike
19TimElsa and Tim
Sheet3
Cell Formulas
RangeFormula
G3:G10G3=IFERROR(LOOKUP(2,1/SEARCH(" "&A$15:A$19&" "," "&TEXTJOIN(" ",1,B3:F3)&" "),B$15:B$19),"")
H3:H10H3=TEXTJOIN(" / ",1,FILTER(B$15:B$19,ISNUMBER(SEARCH(" "&A$15:A$19&" "," "&TEXTJOIN(" ",1,B3:F3)&" ")),""))
 
Last edited:
Upvote 0
Thank you jtakw. I appreciate it.

I tried to simplify the question thinking it may not be possible to use Excel for my issue, but your skill proved me wrong. I actually get the raw data with notes in 5 different columns. Each of them could contain the keyword. So if the keyword cannot be found in one column, the formula looks at the next one until it finds the key word. I tried to use your solution and apply it to other columns but failed. I hope I am not being a pain here. Is it possible to expand the formula over 5 columns?

Partial Match.xlsx
ABCDEFG
1
2Note 1Note 2Note 3Note 4Note 5Keys
3Steve abc def ghiSteve Fox Ltd
4Sam abc def ghiMike abc def ghi klabcdefdef ty76 
5Miss-coding Jasson KeyJasson Key Superstore
6Tom xyz jklklpMike xyz jkl56ip56ip 90sadf 
7Stevenson iop wer yuuAlex rt5Steve iop wer yuuSteve Fox Ltd
8Nov 2021 Elsa and AndyNov 2021 Elsa and Tim 
9Refund Jasson KeyJasson Key Superstore
10abc Walmart 
11
12
13
14NameComplete Name
15MikeMike Miller Associates
16SteveSteve Fox Ltd
17KeyJasson Key Superstore
18TimElsa and Tim
SAP 2021 (2)
Cell Formulas
RangeFormula
G3:G10G3=IFERROR(LOOKUP(2,1/SEARCH('SAP 2021 (2)'!A$15:A$18,B3),'SAP 2021 (2)'!B$15:B$18),"")

I was just trying to answer OP original question as best as I can I understand, I anticipated further inquiries
BTW, your written requirements differs from the requirements in your picture attachments, this is based on your Written description.

Seems like you got it covered (y)
 
Upvote 0
Firstly, with your original sample, the formula suggested by @jtakw could possibly return incorrect results - see cell D10 below.

B10 was not in OP's original sample, otherwise I would've added the spaces in my formula.

Also, if there could be any sort of overlap with the short names, like in cells A5 & A18 below, the previous formula could still return dubious results as shown in G4 below.
An alternative is shown in column H that for a situation like that would list all possible matches and you could AutoFilter that columns for "contains" "/" to manually enter the correct results.

I don't have TEXTJOIN as Peter_SSs and OP has, so my formula manually joins the Text in the 5 cells.
As for the possible Overlap of short names pointed out by Peter_SSs, I also recommend using Unique Name Keys in A15:A19, (e.g. use "Ken" for "Ken and Mike")

Book3.xlsx
ABCDEFG
1
2Note 1Note 2Note 3Note 4Note 5Keys
3Steve abc def ghiSteve Fox Ltd
4Sam abc def ghiMike Miller abcabcdefdef ty76Mike Miller Associates
5Miss-coding Jasson KeyJasson Key Superstore
6Tom xyz jklklpKen & Mike xyz jkl56ip56ip 90sadfKen & Mike
7Stevenson iop wer yuuAlex rt5Steve iop wer yuuSteve Fox Ltd
8Nov 2021 Elsa and AndyNov 2021 Elsa and TimElsa and Tim
9Refund Jasson KeyJasson Key Superstore
10abc Walmart 
11
12
13
14NameComplete Name
15MikeMike Miller Associates
16SteveSteve Fox Ltd
17KeyJasson Key Superstore
18KenKen & Mike
19TimElsa and Tim
Sheet995
Cell Formulas
RangeFormula
G3:G10G3=IFERROR(LOOKUP(2,1/SEARCH(" "&A$15:A$19&" "," "&B3&" "&C3&" "&D3&" "&E3&" "&F3&" "),B$15:B$19),"")
 
Upvote 0
B10 was not in OP's original sample, otherwise I would've added the spaces in my formula.
By 'original sample' I was actually referring to the layout of a single column of text to check, rather than the actual values which are clearly not real.
In any case my point was that short strings especially, like "key" or "tim", could easily appear in longer words in the data & therefore it would be prudent to include the spaces. :)
 
Upvote 0
Thank you Peter_SSs and jtakw. You guys are awesome.

I applied Peter_SSs' solution but for some reason the result comes blank. Maybe my Excel doesn't support TextJoin, but not sure since I am still learning basic Excel. jtakw's latest solution works with one problem that is caused by inconsistent manual data entries in our system.

The problem is that some Key words have been entered without any space with the proceeding/following words/characters. ie. Steve--Fox instead of Steve Fox or MikeMiller instead of Mike Miller. The solution doesn't find these ones. Is there any tweak in the solution that can fix this problem?

Thank you again.
 
Upvote 0
Maybe my Excel doesn't support TextJoin
Test in a blank cell with
=TEXTJOIN(1,1,1)
If that comes back with 1 then you have TEXTJOIN.
If it comes up with #NAME? then you do not have TEXTJOIN. In that case you should edit your profile because that says you have Microsoft 365 which does have TEXTJOIN. :)

1644379010675.png
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,970
Members
448,933
Latest member
Bluedbw

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