Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Count matches in field 1

Status
Not open for further replies.

hondurab

Technical User
Jul 19, 2001
14
US
How might I go about counting the instances of a particular string in a memo field?

For example, in a work log field, I want to count the number of entries for "John Doe".

Please give details - thank you! :)



 
I'm not sure if this is what your looking for but you can always use

=COUNTIF(FirstCell:LastCell,"John Doe"

This will count all of the entries in the range with the string "John Doe".
Mahalo,
cg
 
I think that would work if I had a cell range, by my work log is in a single cell.

Mahalo!
 
To test the number of times a string occurs within a single cell, you can use the following function:

Function CountString(rngWorklog As Range, _
strSearchText As String) As Integer
Dim strWorklog As String
Dim intSubtract As Integer
Dim intFound As Integer
Dim intCount As Integer


strWorklog = Range(rngWorklog.Address).Value
intSubtract = Len(strSearchText)

Do Until InStr(1, strWorklog, strSearchText) = 0
intFound = InStr(1, strWorklog, strSearchText)

strWorklog = Mid(strWorklog, intFound + intSubtract)
intCount = intCount + 1
Loop

CountString = intCount
End Function

To use this function within your worksheet, use the following formula:

=CountString(A1,"test")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top