Word count from word 1 to the first occurance of a particular phrase in a cell

inosent

Board Regular
Joined
Mar 19, 2007
Messages
131
Let's say I have this text in a cell, and I want to count all the words from word 1 to the first occurance of the phrase "Thank you":

"The quick brown fox jumped over the fence to say Hello.

Thank you

The blue car was parked on the street and ..."

The result is 11.

This works great for an overall word count, =IF(LEN(TRIM(M2))=0,0,LEN(TRIM(M2))-LEN(SUBSTITUTE(M2," ",""))+1)

but I only need to count the first part of the text in the cell as noted above
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi,

Try this:


Book1
AB
1The quick brown fox jumped over the fence to say Hello. Thank you The blue car was parked on the street and 11
Sheet625
Cell Formulas
RangeFormula
B1=LEN(TRIM(REPLACE(A1,SEARCH("Thank you",A1),LEN(A1),"")))-LEN(SUBSTITUTE(TRIM(REPLACE(A1,SEARCH("Thank you",A1),LEN(A1),""))," ",""))+1
 
Upvote 0
Try this too:

Excel Workbook
LMN
1
2The quick brown fox jumped over the fence to say Hello.Thank youThe blue car was parked on the street and 11
sheet1
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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