Searching keywords using VBA in excel -not exact match

Mirandazhou

New Member
Joined
Sep 25, 2015
Messages
9
Hi everyone, I'm relatively new to VBA and I am really struggling with the following task..

I am creating a huge excel file, and need to find out the names, from one row
James LEE went to mall todayJames, Lee
Rental payment for Lee JamesJames, Lee
Orders for JAMES LEEJames, Lee
Kim Chazen got hiredKim, Chazen
Salary for Kim ChazenKim, Chazen

<tbody>
</tbody>

I have keyword table as


Kim, Chazen
James, Lee
Yang, Wang

<tbody>
</tbody>

The names shows in different format, sometimes James LEE, LEE James, James M Lee, so I cannot use lookup function directly in excel...

I really appreciate for the help! Thanks!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Excel 2010
ABCDE
1James LEE went to mall todayJames, LeeJames, Lee
2Rental payment for Lee JamesJames, LeeKim, Chazen
3Orders for JAMES LEEJames, Lee
4Kim Chazen got hiredKim, Chazen
5Salary for Kim ChazenKim, Chazen
Sheet1
Cell Formulas
RangeFormula
B1{=INDEX($E$1:$E$2,MATCH(TRUE,ISNUMBER(FIND(UPPER(MID($E$1:$E$2,FIND(",",$E$1:$E$2)+2,LEN($E$1:$E$2))),UPPER(A1))),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Excel 2010
ABCDE
1James LEE went to mall todayJames, LeeJames, Lee
2Rental payment for Lee JamesJames, LeeKim, Chazen
3Orders for JAMES LEEJames, Lee
4Kim Chazen got hiredKim, Chazen
5Salary for Kim ChazenKim, Chazen

<tbody>
</tbody>
Sheet1

Array Formulas
CellFormula
B1{=INDEX($E$1:$E$2,MATCH(TRUE,ISNUMBER(FIND(UPPER(MID($E$1:$E$2,FIND(",",$E$1:$E$2)+2,LEN($E$1:$E$2))),UPPER(A1))),0))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
Thank you for your help. Maybe I did not describe well... the other column (B) is what I want, not shown in excel.......
 
Last edited:
Upvote 0
Really sorry for the confusion. It is my first time posting here..

Before:
1
James LEE went to mall today
2
Rental payment for Lee James
3
Orders for JAMES LEE
4
Kim Chazen got hired
5
Salary for Kim Chazen

<tbody>
</tbody>

After:
James LEE went to mall today
James, Lee
Rental payment for Lee James
James, Lee
Orders for JAMES LEE
James, Lee
Kim Chazen got hired
Kim, Chazen
Salary for Kim Chazen
Kim, Chazen

<tbody>
</tbody>

My keywords table:
Kim, Chazen
James, Lee
Yang, Wang

<tbody>
</tbody>

Thank you again for your help!! Really appreciate!
 
Upvote 0
My formula gives you what you want. You just need to update the cell references to match the true locations in your workbook. My $E$1:$E$2 is your keyword table. The formula in B1 is copied down. Be sure to follow the instructions at the bottom of post#2.
 
Upvote 0
Thank you so much LloydFinancials!! Your formula works really well, I thought only VBA can solve the problem before... Thank you!

My formula gives you what you want. You just need to update the cell references to match the true locations in your workbook. My $E$1:$E$2 is your keyword table. The formula in B1 is copied down. Be sure to follow the instructions at the bottom of post#2.
 
Upvote 0
Hi LloydFinancials, sorry to bother you again, I found out an issue when I applied the formula....


My keywords are a large set, say E2-E600, and my dataset is A2-A2000,

When I did the A1500, the keywords was E 350, when I set the match area to be E2-E600, it might appear to be another name, which actually does not include in A1500; If I changed the match area to be E300-E600, the result was different again; of when I change the match area to E340-E360, the result was correct

Do you know why it happens? Thank you a lot!
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,303
Members
449,218
Latest member
Excel Master

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