Search for Specific Words in a Cell

pilot330

Board Regular
Joined
Feb 19, 2004
Messages
57
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm using the following formula to extract specific words from a cell, in this case anything that contains ": stays". I would also like the same function to search and return other specific text in the same cell, for example anything that also contains ": should stay" or ": will stay:", but I'm having trouble doing so.

=TRIM(LEFT(SUBSTITUTE(MID(Z2,SEARCH(": stays",Z2)+2,255),":",REPT(" ",255)),255))

Any help appreciated please!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi

Excel Formula:
=SUBSTITUTE(LOOKUP(9^9,SEARCH({": stays".": should stay".": will stay"},Z2),{": stays".": should stay".": will stay"}),": ","")
 
Upvote 0
Thanks for the reply. Apologies for perhaps not fully explaining what I need...

The formula would need to return *all* words between the colons that begin with ": stays ...."" , ": will stay...." e.g..... ": stays at the white house:" , ": will stay at the hotel:"

Thanks again
 
Upvote 0
Hi,

I think you should show at least a handful of sample text strings, preferably with XL2BB or at least in table format, so helpers can copy for testing, and explain exactly what you want extracted.
 
Upvote 0
It's always good to present up to 10 real life examples with the wished results.
It there more text before or after'? Are there more colons?
Are there numbers/dates?
 
Upvote 0
Thanks for the replies. A cells contents would typically look like this...

modest handicap hurdler: won at Galway (by 6½ lengths from Yamato) in September: 150/1, tailed-off fifth of 7 to Haut En Couleurs in maiden at Leopardstown on chasing debut: stays 25f: acts on heavy going.

smallish gelding: winning hurdler: fair form over fences: left Joseph Patrick O'Brien/off 22 months, looked rusty when well held last time: will stay 2¾m: acts on good to soft going: has worn tongue tie, including usually of late.

useful-looking gelding: winning hurdler: fairly useful chaser: let down by jumping when pulled up last time: should stay 23f: acts on soft going.

 
Upvote 0
Hi,

Thanks for posting samples, I'm assuming those are 3 sample text strings in 3 separate cells, will this work for you:

Book3.xlsx
ABC
1modest handicap hurdler: won at Galway (by 6½ lengths from Yamato) in September: 150/1, tailed-off fifth of 7 to Haut En Couleurs in maiden at Leopardstown on chasing debut: stays 25f: acts on heavy going.stays 25f
2smallish gelding: winning hurdler: fair form over fences: left Joseph Patrick O'Brien/off 22 months, looked rusty when well held last time: will stay 2¾m: acts on good to soft going: has worn tongue tie, including usually of late.will stay 2¾m
3useful-looking gelding: winning hurdler: fairly useful chaser: let down by jumping when pulled up last time: should stay 23f: acts on soft going. should stay 23f
Sheet973
Cell Formulas
RangeFormula
C1:C3C1=TRIM(LEFT(SUBSTITUTE(MID(A1,1/LOOKUP(2,1/SEARCH({": stay",": will stay",": should stay"},A1))+2,99),":",REPT(" ",99)),99))
 
Upvote 0
Another option
+Fluff 1.xlsm
AB
1
2modest handicap hurdler: won at Galway (by 6½ lengths from Yamato) in September: 150/1, tailed-off fifth of 7 to Haut En Couleurs in maiden at Leopardstown on chasing debut: stays 25f: acts on heavy going.stays 25f
3smallish gelding: winning hurdler: fair form over fences: left Joseph Patrick O'Brien/off 22 months, looked rusty when well held last time: will stay 2¾m: acts on good to soft going: has worn tongue tie, including usually of late.will stay 2¾m
4useful-looking gelding: winning hurdler: fairly useful chaser: let down by jumping when pulled up last time: should stay 23f: acts on soft going. should stay 23f
Lists
Cell Formulas
RangeFormula
B2:B4B2=FILTERXML("<k><m>"&SUBSTITUTE(A2,":","</m><m>")&"</m></k>","//m[contains(.,'stay')]")
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

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