+ Reply to Thread
Results 1 to 4 of 4

Count all the words in a string before a specific word occur

  1. #1
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Count all the words in a string before a specific word occur

    Hi,

    Is it possible to count the number of words in a string before a specific word?
    Eg. John has left the building - count all before "building"=4
    Andrew was there the night before - count all before "there"=2

    I know how to count all the characters before another one and all the words in a string. Is it possible to count with criteria in string?

    Regards,
    Paul
    Click the * to say thanks.

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Count all the words in a string before a specific word occur

    With the sentence in A1 and specific word in B1

    Please try C1

    =LEN(LEFT(A1,FIND(B1,A1)))-LEN(SUBSTITUTE(LEFT(A1,FIND(B1,A1))," ",""))

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Count all the words in a string before a specific word occur

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Count all the words in a string before a specific word occur

    Many thanks to both of you. I've ended up using Bo_Ry's formula, but both of them will do. Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find / Extract Word & Words after a Specific Word
    By roseuz in forum Excel General
    Replies: 8
    Last Post: 07-05-2017, 01:07 PM
  2. Replies: 4
    Last Post: 10-25-2016, 04:45 PM
  3. Replies: 1
    Last Post: 02-21-2016, 02:39 AM
  4. Replies: 15
    Last Post: 10-12-2014, 08:53 AM
  5. program a formula to count number of times event occur before a specific time.
    By yinxzon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2014, 04:15 AM
  6. How to open a Word.doc using VBA and count the words in the word.doc?
    By eijoah in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2007, 12:58 AM
  7. [SOLVED] search for a specific word and copy the word and the preceeding words until a comma
    By DHANANJAY in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-31-2005, 09:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1