+ Reply to Thread
Results 1 to 5 of 5

How do you count how many times a certain character appears in a cell?

  1. #1
    Registered User
    Join Date
    03-26-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    26

    How do you count how many times a certain character appears in a cell?

    How does one count how often a certain character or string appears within another string? For instance counting the number of spaces in a cell, or counting how often the word "the" appears.

    Is there a direct function to do this or does one need to play around with combining different functions?

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: How do you count how many times a certain character appears in a cell?

    Hi Skywalker,

    To count the number of "the" in cell J20 (change cell reference to suit) use this...

    =SUM(LEN(J20)-LEN(SUBSTITUTE(J20,"the","")))/LEN("the")

    ...and simiarily to count the number of spaces in cell J20 (again change the cell reference to suit), use this:

    =SUM(LEN(J20)-LEN(SUBSTITUTE(J20," ","")))/LEN(" ")

    You can change the formula for any character you wish.

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How do you count how many times a certain character appears in a cell?

    Hi

    With your sting in A1 and the word or the special character in A2, try this.

    =(LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),LOWER(A2),"")))/LEN(A2)

    Is this, works for you?
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

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

    Re: How do you count how many times a certain character appears in a cell?

    Hello
    or a udf found here.

    http://www.vbaexpress.com/kb/getarticle.php?kb_id=235

    =countchar(A1," ")
    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

  5. #5
    Registered User
    Join Date
    03-26-2009
    Location
    New Jersey
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: How do you count how many times a certain character appears in a cell?

    Thanks guys!

+ 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