+ Reply to Thread
Results 1 to 15 of 15

Counting Repeated Words in a Cell

  1. #1
    Registered User
    Join Date
    02-09-2007
    Posts
    11

    Counting Repeated Words in a Cell

    Is there a formula that will count the number of times a character or word appears in a cell? I have downloaded fields from a database where each item is separated by the word "and". For example the field would say Atlanta_and_Chicago_and_Detroit. I am trying to count the number of cities that show up in this field so in this example I would want it to return 3. Is there a simple formula to count the number of "and"s in a cell?

    Thanks in advance

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Counting Repeated Words in a Cell

    Quote Originally Posted by aalbers View Post
    Is there a simple formula to count the number of "and"s in a cell?

    Thanks in advance
    Hmmm...simple?...You be the judge.
    With A1 containing text that may contain 1 or more names separated by "and"

    This formula counts the number of cities in A1. It returns 0 if the cell contains no text
    .
    Please Login or Register  to view this content.

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    02-09-2007
    Posts
    11

    Re: Counting Repeated Words in a Cell

    Thanks, that worked great. I never would have thought of approaching it that way.

    Thanks again.

  4. #4
    Registered User
    Join Date
    02-19-2012
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Counting Repeated Words in a Cell

    I have a similar issue with counting repeated words in a single cell.

    I have a list of equipment in a single cell that clients have hired. It looks like this:

    A1: projector, microphone, laptop etc

    Sometimes they hire more than one of the same thing like this (a different client for each row)

    A1: projector, projector, microphone, laptop
    A2: microphone, projector
    A3: projector, projector

    I then need to count the total number of each piece of equipment in the data range $A:$A. So I am using the COUNTIF function to count the number of times a word appears (in this case 'projector') in the data range $A:$A but it will only count each cell once instead of counting each word once.

    HELP!!

  5. #5
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Counting Repeated Words in a Cell

    count how many "projector" = 5

    =SUM(LEN(A1:A3)-LEN(SUBSTITUTE(A1:A3,"projector","")))/LEN("projector")

    sorry

    array formula

    ctrl + shift + enter

    not enter only.
    Last edited by vlady; 02-19-2012 at 09:54 PM. Reason: sorry array formula
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  6. #6
    Registered User
    Join Date
    02-19-2012
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Counting Repeated Words in a Cell

    AWESOME!!

    I was scratching my head for a while until you added the array part

  7. #7
    Registered User
    Join Date
    02-19-2012
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Counting Repeated Words in a Cell

    Is there a way that you can make 'projector' a reference to another cell so that i can copy the formula without having to write it over and over?

  8. #8
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Counting Repeated Words in a Cell

    you mean like this, assume the words will be in cell A5 that will be counted.

    =SUM(LEN(A1:A3)-LEN(SUBSTITUTE(A1:A3,$A$5,"")))/LEN($A$5)

  9. #9
    Registered User
    Join Date
    02-19-2012
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Counting Repeated Words in a Cell

    great!

    it all works well, is there a way to make it case INsensitive?

  10. #10
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Counting Repeated Words in a Cell

    substitute is a case sensitive function..

    you can use the upper() lower() proper()

    SUBSTITUTE(lower(A1:A3),$A$5,"")

  11. #11
    Registered User
    Join Date
    05-04-2012
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Counting Repeated Words in a Cell

    [NM: post not related.]
    Last edited by JimD; 06-27-2012 at 08:59 AM.

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Counting Repeated Words in a Cell

    JimD,

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  13. #13
    Registered User
    Join Date
    11-06-2013
    Location
    Hyderabad
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Counting Repeated Words in a Cell

    Hi, I am new to this forum and new to using excel formula also . I found this thread while searching in google and registered to this group .

    Below I have described the scenario.

    A1 :projector , projector
    A2 :Mad , Projector_d
    projeCtor
    projectoR

    A5 :projector
    I applied =SUM(LEN(A1:A3)-LEN(SUBSTITUTE(LOWER(A1:A3),$A$5,"")))/LEN($A$5) this , I got correct results .

    For this one below :

    K1 : Audio
    K2 : Audio , audio , mad
    Audio, mad
    Audio
    audio

    K3 :Audio

    K5 :Audio
    I apply same formula here : =SUM(LEN(K1:K3)-LEN(SUBSTITUTE(LOWER(K1:K3),$K$5,"")))/LEN($K$5) , it does not work , can someone help.

    Thanks.

  14. #14
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Counting Repeated Words in a Cell

    =SUMPRODUCT((MID(A1,ROW(1:100),LEN("and"))="and")*1)+1

  15. #15
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,884

    Re: Counting Repeated Words in a Cell

    @jinkachandu
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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