Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009

    Formula for field character search

    Need help in writing formula for determining number of alphabetical characters in a field i.e. number of D's, E's, etc.

    Assume this is simple but have not been able to figure out using help in EXCEL or MS Works.
    Thank You.

  2. #2
    Join Date
    Jan 2011

  3. #3
    Join Date
    Jan 2002
    Bay Area
    The attached Excel workbook shows an example of using VBA code to count the number of characters from A to Z found in a string of text. I can't image doing this with a formula in a cell.
    The code converts lower case letters to upper case, so "a" is counted as "A".
    Good luck.

    Private Sub cmdRunCode_Click()
    Dim strAlphabet As String, strText As String
    Dim strLetter As String
    Dim i As Integer, intTotal As Integer
        strText = Cells(1, 1).Value
        For i = 1 To Len(strAlphabet)
            strLetter = Mid(strAlphabet, i, 1)
            Cells(i, 2).Value = strLetter
            Cells(i, 3).Value = Count_Letter(strLetter, strText)
            totalLetters = totalLetters + Cells(i, 3).Value
        Next i
        Cells(1, 4).Value = "Total:"
        Cells(1, 5).Value = totalLetters
    End Sub
    Private Function Count_Letter(Letter_To_Count As String, myText As String) As Integer
    Dim j As Integer, ltrCount As Integer
        For j = 1 To Len(myText)
            If Letter_To_Count = UCase(Mid(myText, j, 1)) Then
                ltrCount = ltrCount + 1
            End If
        Next j
        Count_Letter = ltrCount
    End Function
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts