+ Reply to Thread
Results 1 to 7 of 7

Formula to Count Occurences of a Word in a Sentence Within a Cell

  1. #1
    Forum Contributor
    Join Date
    07-28-2008
    Location
    Leamington Spa, UK
    MS-Off Ver
    2010
    Posts
    142

    Question Formula to Count Occurences of a Word in a Sentence Within a Cell

    Hi All,

    I am after the formula to count the occurrence of, for instance the word 'the' in a sentence/paragraph that is contained in Cell A1. Cell B1 should return the quantity of times the word 'the' has been found in Cell A1.
    Thanks in Advance,

    Cheers,
    Mark
    Last edited by R_S_6; 11-11-2009 at 09:00 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Formula to Count Occurences of a Word in a Sentence Within a Cell

    one way

    =(LEN(A1)-LEN(SUBSTITUTE(A1,"the","")))/3

    Although this will count the within words, such aste there
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Formula to Count Occurences of a Word in a Sentence Within a Cell

    EDIT: first section is repetition of Andy's post above

    A basic

    =(LEN(A1)-LEN(SUBSTITUTE(A1,"the","")))/LEN("the")

    is risky given the word could be embedded... that said if it's a paragraph there's likely to be variations on punctuation, correct ?
    (ie words split by space / comma / ? / full stop etc etc...)

    If so a SUMPRODUCT (based on space delimiter) would not be watertight either... we'd need to know the punctuation variants I think.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Formula to Count Occurences of a Word in a Sentence Within a Cell

    Hi,

    Please Login or Register  to view this content.
    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Contributor
    Join Date
    07-28-2008
    Location
    Leamington Spa, UK
    MS-Off Ver
    2010
    Posts
    142

    Question Re: Formula to Count Occurences of a Word in a Sentence Within a Cell

    Thank you all for your swift replies!

    I have pasted in Richard's code and it seems to work fine. In terms of punctuation I'm not too worried, however is there a way of matching the word without necessarily matching the case. I.e. searching 'the' would also find 'The' and 'THE' etc...?

    Thanks again to all of you!
    Cheers,
    Mark

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Formula to Count Occurences of a Word in a Sentence Within a Cell

    Just make the formula all upper case.

    =(LEN(A1)-LEN(SUBSTITUTE(UPPER(A1),"THE","")))/3

  7. #7
    Forum Contributor
    Join Date
    07-28-2008
    Location
    Leamington Spa, UK
    MS-Off Ver
    2010
    Posts
    142

    Thumbs up Re: Formula to Count Occurences of a Word in a Sentence Within a Cell

    That's great thanks Andy!

    Cheers,
    Mark

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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