+ Reply to Thread
Results 1 to 5 of 5

Frequency count

  1. #1
    Registered User
    Join Date
    08-15-2007
    Posts
    13

    Frequency count

    Hi all.

    I wonder whether you can help me.

    I am trying to find the frequency that one letter occurs in a given text string.

    For instance - HHHAAAAH - I want to now how many H's and how many A's occur (4 H and 4 A).

    Does anybody know how to accomplish this?

    Many thanks

    Matt

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try

    =LEN(A1)-LEN(SUBSTITUTE(SUBSTITUTE(A1,"H",""),"H",""))

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    08-15-2007
    Posts
    13
    Spot on! Top work!!

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Nearly

    should of being

    =LEN(A1)-LEN(SUBSTITUTE(SUBSTITUTE(A1,"H",""),"h",""))

    Just in case you have a mix of proper and lower case

    VBA Noob

  5. #5
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,676
    Or if you want to count both upper and lower case together

    =LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),"h",""))

+ 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