Count the number of WORDS before a certain word shows in string

getstuffdone

New Member
Joined
Dec 16, 2016
Messages
1
I was trying to figure out a way to count the number of words before a certain word shows in a string.
For example: I have to go shopping today.
Specific word to find: Shopping
Formula Result: 4

So there were 4 words before the word "shopping" came up. I was thinking of just cutting the cell wherever the specific word was and split it into two columns and then counting the total amount of words... but I was wondering if anyone had a quicker way.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Welcome to the forum.

Maybe:

ABCD
1I have to go shopping today.shopping
24

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
D2=IFERROR(LEN(LEFT(A1,FIND(D1,A1)))-LEN(SUBSTITUTE(LEFT(A1,FIND(D1,A1))," ","")),0)

<tbody>
</tbody>

<tbody>
</tbody>
 
Last edited:
Upvote 0
Welcome to the forum.

Try

=LEN(REPLACE(A1,FIND(E1,A1),999,""))-LEN(SUBSTITUTE(REPLACE(A1,FIND(E1,A1),999,"")," ",""))

A1 is the text string
E1 is the word you want to find
 
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,527
Members
449,037
Latest member
tmmotairi

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