ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   re-occuring text 99 (https://www.excelbanter.com/excel-programming/374818-re-occuring-text-99-a.html)

RaY

re-occuring text 99
 
Does anyone know of a function in VBA that counts number of time text
re-occurs in a string.

ie Test String ... T appears 3 times.

I wrote a function that does a character by character check but its very
slow when checking large amounts of data.

Thank you (if this post appears twice its because my comp keeps bombing)



--
Ray

Bob Phillips

re-occuring text 99
 
=LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),"t",""))

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ray" wrote in message
...
Does anyone know of a function in VBA that counts number of time text
re-occurs in a string.

ie Test String ... T appears 3 times.

I wrote a function that does a character by character check but its very
slow when checking large amounts of data.

Thank you (if this post appears twice its because my comp keeps bombing)



--
Ray




Bob Phillips

re-occuring text 99
 
if you want VBA

Function CountOccurances(val As String, check As String)
CountOccurances = Len(val) - _
Len(Replace(LCase(val), LCase(check), ""))
End Function


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Ray" wrote in message
...
Does anyone know of a function in VBA that counts number of time text
re-occurs in a string.

ie Test String ... T appears 3 times.

I wrote a function that does a character by character check but its very
slow when checking large amounts of data.

Thank you (if this post appears twice its because my comp keeps bombing)



--
Ray





All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com