+ Reply to Thread
Results 1 to 2 of 2

Help w/ project. Counting upper and lower case characters in a cell.

  1. #1

    Help w/ project. Counting upper and lower case characters in a cell.

    Here's the task I'm trying to complete:

    Take text from a cell.
    Count all uppercase letters.
    Count all lower case letters.

    I've figured out how to count the total letters excluding spaces using
    the LEN and SUBSTITUTE commands, but I'm stuck on how to count how many
    uppercase and lower case letters there are. Can anyone point me in the
    right direction?


  2. #2
    RB Smissaert
    Guest

    Re: Help w/ project. Counting upper and lower case characters in a cell.

    This is a fast function to count upper case characters.
    You can work out for yourself how to do lower case.


    Function CountUppers(ByVal strString As String) As Long

    Dim aByte() As Byte
    Dim i As Long

    aByte() = strString

    For i = 0 To UBound(aByte) Step 2
    If aByte(i) < 91 Then
    If aByte(i) > 64 Then
    CountUppers = CountUppers + 1
    End If
    End If
    Next

    End Function


    Sub test()

    MsgBox CountUppers(Cells(1))

    End Sub


    RBS


    <[email protected]> wrote in message
    news:[email protected]...
    > Here's the task I'm trying to complete:
    >
    > Take text from a cell.
    > Count all uppercase letters.
    > Count all lower case letters.
    >
    > I've figured out how to count the total letters excluding spaces using
    > the LEN and SUBSTITUTE commands, but I'm stuck on how to count how many
    > uppercase and lower case letters there are. Can anyone point me in the
    > right direction?
    >



+ 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