+ Reply to Thread
Results 1 to 3 of 3

character count

  1. #1
    ben
    Guest

    character count

    I seem to have misplaced a function.


    What is hte method for counting how many times a specific character occurs
    inside a string without looping through it?
    eg...

    a = FUCNTIONCHARSEARCH("The quick brown fox ran over the yard.","t")
    a = 2


    ?




    --
    When you lose your mind, you free your life.
    Ever Notice how we use '' for comments in our posts even if they aren''t
    expected to go into the code?

  2. #2
    Chip Pearson
    Guest

    Re: character count

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

    or in VBA

    Dim L As Long
    Dim S As String
    S = "abcda"
    L = Len(S) - Len(Replace(S, "a", ""))
    Debug.Print L


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com

    "ben" <&&&&[email protected](remove this if mailing direct)>
    wrote in message
    news:[email protected]...
    >I seem to have misplaced a function.
    >
    >
    > What is hte method for counting how many times a specific
    > character occurs
    > inside a string without looping through it?
    > eg...
    >
    > a = FUCNTIONCHARSEARCH("The quick brown fox ran over the
    > yard.","t")
    > a = 2
    >
    >
    > ?
    >
    >
    >
    >
    > --
    > When you lose your mind, you free your life.
    > Ever Notice how we use '' for comments in our posts even if
    > they aren''t
    > expected to go into the code?




  3. #3
    ben
    Guest

    Re: character count

    ah, brilliant

    thank you

    --
    When you lose your mind, you free your life.
    Ever Notice how we use '' for comments in our posts even if they aren''t
    expected to go into the code?


    "Chip Pearson" wrote:

    > =LEN(A1)-LEN(SUBSTITUTE(A1,"a",""))
    >
    > or in VBA
    >
    > Dim L As Long
    > Dim S As String
    > S = "abcda"
    > L = Len(S) - Len(Replace(S, "a", ""))
    > Debug.Print L
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    > "ben" <&&&&[email protected](remove this if mailing direct)>
    > wrote in message
    > news:[email protected]...
    > >I seem to have misplaced a function.
    > >
    > >
    > > What is hte method for counting how many times a specific
    > > character occurs
    > > inside a string without looping through it?
    > > eg...
    > >
    > > a = FUCNTIONCHARSEARCH("The quick brown fox ran over the
    > > yard.","t")
    > > a = 2
    > >
    > >
    > > ?
    > >
    > >
    > >
    > >
    > > --
    > > When you lose your mind, you free your life.
    > > Ever Notice how we use '' for comments in our posts even if
    > > they aren''t
    > > expected to go into the code?

    >
    >
    >


+ 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