Excel Formula for Finding Repeated Words in a Cell

Posted on November 11th, 2008 in Learn Excel - 11 comments

excel-repeat-word-formula-help

If you ever need to know whether a particular word is repeated in a cell (for eg: a file extension or telephone number or name of the customer) here is how you can find it.

=if(lower(cell-with-text)<>SUBSTITUTE(lower(cell-with-text),lower(word-to-check),"",2),"Yes","No")

We are using substitute() to replace the second occurance of a particular word and then compare this with original cell contents. If both are not equal, we know that the word is repeated.

For eg: =if(lower("all cats are dogs, but not all dogs are cats")<>SUBSTITUTE(lower("all cats are dogs, but not all dogs are cats"),lower("cat"),"",2),"Yes","No") would return “yes”

See related posts for more text processing using excel hacks.

Written by Chandoo
Tags: , , , , , , , , , , ,
Home: Chandoo.org Main Page
? Doubt: Ask an Excel Question

11 Responses to “Excel Formula for Finding Repeated Words in a Cell”

  1. kidakaka says:

    Nice Chandoo!! So I can now do pattern matching and tracking!

  2. Michelle says:

    Very useful!!! I had no idea it could be done... thank you!!

  3. [...] bookmarks tagged repeated Excel Formula for Finding Repeated Words in a Cell saved by 1 others     shikaiangela bookmarked on 11/11/08 | [...]

  4. azmat says:

    hi chandoo,
    i got this below formulae on another site which picks all the text appearing after "/" in a cell....however i can't understand how it works....specially if you could tell me what does this REPT function and 255 value does in this formulae.....

    =TRIM(RIGHT(SUBSTITUTE(B23,"/",REPT(" ",255)),255))

    u can call me a novice wrt formulaes......

  5. Chandoo says:

    @Kida... yeah, you can do some basic pattern matching using this other text manipulation functions.

    @Michelle: you are welcome 🙂

    @Azmat: Thanks for sharing this formula with all. Even I didn't know about this and it definitely goes in to my favorite formula tricks.

    here is how it works:
    - the formula produces portion of the cell contents after last "/" symbol.
    - assuming, the last part is not longer than 255 characters (usually the case)
    - It replaces every "/" with 255 spaces (the rept() function is doing that)
    - Now, it uses right() to extract right most 255 characters. Which probably has a bunch of spaces and then the last portion and another bunch of space.
    - Finally it uses trim to cut down spaces to provide just the string.

    If your string has more than 255 characters after the last "/" symbol, you can use even larger number like 999 in rept() and right().

  6. Glenn says:

    Is there a formula if I want to see if a word is repeated in a column?

  7. Chandoo says:

    @Glenn you can try countif()

    assuming you want to see if word "Glenn" is repeated in the range C1:C20, write something like =IF(COUNTIF(C1:C20,"*Glenn*")>1,"Repeated","Not Repeated")

  8. Mike says:

    Great formula! Thanks so much for posting it.

  9. Tarun says:

    Hi,

    I want to know what text is repeated maximum number of time in a row.

    Eg. Ram, Amitabh, Ravan, Ram, Sita, Tarun, Ram, Chandoo
    should result Ram (3 times)

    Nos. of time Ram is repeated can be calculated by countif function, but how to find what Text is repeated maximum times?

  10. Riduan says:

    Please help!!! Looked everywhere but can't get this to work.

    I have a column where each row containing different sentences. How do I check for duplicate word(s) in each cell in this particular column of various sentences?

Leave a Reply