Find a specific word in a cell before a specific word

aghaffar82

Board Regular
Joined
Jun 13, 2019
Messages
65
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have this string in cell O1201 and formula in cell U1201

String:
Attorney/ownerLaw Office of Mark A. SkeltonCurrentLaw Office of Mark A. Skelton has served East Tennessee since 1983. The attorneys with the firm include Mark Albert Skelton and Amy Kathleen Skelton.

Formula:
=IFERROR(IF(IFERROR(SEARCH(B1201,O1201),IFERROR(SEARCH(LEFT(B1201,(FIND(" ",B1201,1)-1)),O1201),IFERROR(SEARCH(TRIM(RIGHT(SUBSTITUTE(B1201," ",REPT(" ",100)),100)),O1201),"")))<SEARCH("Current",O1201),"Yes","No"),"N/A")

Text in cell B1201:
Mark Albert Skelton

The formula is resulting in a "No", I want it to be a "Yes", the reason it is returning "No" is understood that it is finding an exact match of the value of B1201 after the word Current being the first condition, but I just want it to stay within the string before the word "Current" and if it doesn't find an exact match of the value in B1201 before the word Current, it should then look for first name and last name parts but also before the word Current.

Hope it makes sense, happy to clarify it further if needed. And thank you in advance for your kind consideration.
Best Regards
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,774
Office Version
  1. 365
Platform
  1. Windows
How about
Excel Formula:
=IFERROR(IF(IFERROR(SEARCH(B1201,LEFT(O1201,SEARCH("current",O1201))),IFERROR(SEARCH(LEFT(B1201,(FIND(" ",B1201,1)-1)),O1201),IFERROR(SEARCH(TRIM(RIGHT(SUBSTITUTE(B1201," ",REPT(" ",100)),100)),O1201),"")))<SEARCH("Current",O1201),"Yes","No"),"N/A")
 
Solution

aghaffar82

Board Regular
Joined
Jun 13, 2019
Messages
65
Office Version
  1. 365
Platform
  1. Windows
Thank you so much, worked like a charm, Best Regards
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,774
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,995
Messages
5,639,446
Members
417,090
Latest member
schoelleya

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