+ Reply to Thread
Results 1 to 3 of 3

Custom Function: Count number of strings in range?

  1. #1
    Registered User
    Join Date
    10-25-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Custom Function: Count number of strings in range?

    I am trying to create a custom function that would allow me to select a range and return the number of cells that contain strings within that range.

    Example: If I select a range of 8 Cells containing the following list, it would return the value 3
    abc
    123
    10/25/2010
    True
    def
    False
    =A10-B10
    ghi

    It would return three because "abc" "def" and "ghi" are the only three strings within my selection.

    I am lost with figuring out how to determine if the cell contains a string. Any ideas?

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Custom Function: Count number of strings in range?

    Without having a sample to see the values in question... you might find:

    Please Login or Register  to view this content.
    will give you the desired result
    (the ? itself is not nec. required depends on whether formula nulls should be treated as text or not - remove ? if they should be included)

  3. #3
    Registered User
    Join Date
    10-25-2010
    Location
    New York, NY
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Custom Function: Count number of strings in range?

    Thanks a lot! I was able to create a custom function using your help.

    Public Function StringCount(myRange As Range) As Integer

    StringCount = Application.WorksheetFunction.CountIf(myRange, "?*")

    End Function

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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