If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Applications & Tools > Formula for field character search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-02-09, 22:09
scorpio1945 scorpio1945 is offline
Registered User
 
Join Date: Dec 2009
Posts: 1
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.
Reply With Quote
  #2 (permalink)  
Old 02-03-11, 14:08
john_collins john_collins is offline
Registered User
 
Join Date: Jan 2011
Posts: 14
Reply With Quote
  #3 (permalink)  
Old 02-14-11, 21:44
JerryDal JerryDal is offline
Registered User
 
Join Date: Jan 2002
Location: Bay Area
Posts: 473
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.
Jerry

Code:
Private Sub cmdRunCode_Click()
Dim strAlphabet As String, strText As String
Dim strLetter As String
Dim i As Integer, intTotal As Integer

    strAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    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
File Type: zip CountLetters.zip (9.7 KB, 1 views)
Reply With Quote
Reply

Tags
alphabetical character, formula

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On