Find specific text

mattyman

New Member
Joined
Feb 15, 2004
Messages
22
Hello All

I need to pull a specific word from a string of text in a cell and have that word shown in an adjacant cell.
For example A1 will contain the text "Smith Sun Alliance Pension Fund"
I need B2 to show "Pension". I cannot use any filtering or text to columns as the word Pension can be anywhere within the text in A1 and I have thousands of entries. So I need a function.

Help would be as always greatly appreciated.

Thanks

Matt
 
A1-earth
A2-earthquake
A3-earthworm
A4-pearleartherase
A5-goodeartherase

<tbody>
[TD="width: 64, align: right"]1[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"]erase[/TD]
[TD="width: 64"]earth[/TD]

[TD="align: right"]1[/TD]

[TD="align: right"]1[/TD]

[TD="align: right"]6[/TD]

[TD="align: right"]5[/TD]

</tbody>


i have data in A1:A5

I wanted to find out rows with the word "earth" on it. that means the result should be row1 only.


WHEN i applied -search("earth",A1) i got the digits as answers.in col B
when i applied your formula-=IF(COUNT(SEARCH($E$1&" ",A1&" ")),"erase","") i got unexpected results.in col C .kindly see it and comment please.
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
A1-earth
A2-earthquake
A3-earthworm
A4-pearlearth
erase
A5-goodearth
erase

<TBODY>
[TD="align: right"]1
[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"]erase
[/TD]
[TD="width: 64"]earth
[/TD]

[TD="align: right"]1
[/TD]

[TD="align: right"]1
[/TD]

[TD="align: right"]6
[/TD]

[TD="align: right"]5
[/TD]

</TBODY>


i have data in A1:A5

I wanted to find out rows with the word "earth" on it. that means the result should be row1 only.


WHEN i applied -search("earth",A1) i got the digits as answers.in col B
when i applied your formula-=IF(COUNT(SEARCH($E$1&" ",A1&" ")),"erase","") i got unexpected results.in col C .kindly see it and comment please.

Try...

=IF(COUNT(SEARCH("-"&$E$1&" ","-"&A1&" ")),"erase","")
 
Upvote 0
Hi you could try this in Aladin form with Earth in E1

=IF(LEFT(A1,6)=$E$1&" ","erase",IF(COUNT(SEARCH(" "&$E$1&" ",A1)=1),"erase",IF(COUNT(SEARCH(" "&$E$1,A1)=1),"erase","")))

It will catch the string if the text starts with "Earth "

or if the text is " earth "

or if the text is " earth"

Cheers

ps just occurred to me probably an OR in that formula would shorten it !
 
Last edited:
Upvote 0
Hi you could try this in Aladin form with Earth in E1

=IF(LEFT(A1,6)=$E$1&" ","erase",IF(COUNT(SEARCH(" "&$E$1&" ",A1)=1),"erase",IF(COUNT(SEARCH(" "&$E$1,A1)=1),"erase","")))

It will catch the string if the text starts with "Earth "

or if the text is " earth "

or if the text is " earth"

Cheers

ps just occurred to me probably an OR in that formula would shorten it !

Try post #32...
 
Upvote 0
Just checked it's shorter

=IF(OR(LEFT(A1,6)=$E$1&" ",COUNT(SEARCH(" "&$E$1&" ",A1)),COUNT(SEARCH(" "&$E$1,A1))),"erase","")

Cheers

ps I check #32 only works if "-" precedes the word earth as in -earth. I wasn't sure if evergreen really meant that to be the case. In my formula if you have -earth in E1 it will indentify all instances of the word in E1 no matter where it is beginning, middle or end of the text. :)
 
Last edited:
Upvote 0
Just checked it's shorter

=IF(OR(LEFT(A1,6)=$E$1&" ",COUNT(SEARCH(" "&$E$1&" ",A1)),COUNT(SEARCH(" "&$E$1,A1))),"erase","")

Cheers

ps I check #32 only works if "-" precedes the word earth as in -earth. I wasn't sure if evergreen really meant that to be the case. In my formula if you have -earth in E1 it will indentify all instances of the word in E1 no matter where it is beginning, middle or end of the text. :)

The OP is looking for earth, not for -earth...
 
Upvote 0
The OP is looking for earth, not for -earth...

Exactly what I think.

Evergreen is looking for a word like "event" or "earth" and not "-earth" which is why my formula is as it is.

His request wasn't totally clear.

Btw what does OP mean I guessing it's code for evergreen ?
 
Upvote 0
Well I'm glad you persevered and got the solution you were looking for evergreen it's been a pleasure and I have picked up a few insight along the way. Congrats Aladin I must have misunderstood evergreen need but alls well that ends well :)
 
Upvote 0

Forum statistics

Threads
1,223,914
Messages
6,175,351
Members
452,638
Latest member
Oluwabukunmi

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