View Full Version : Solved: how often does a string contain a substring
marcelma
10-11-2010, 04:28 AM
hello,
is there any ready function which can determine how often a certain substring is contain inside a string or do I have to check it with a loop?
thanks a lot in advance,
Marcel
Tinbendr
10-11-2010, 07:00 AM
Well, sort of.
Sub CountWord()
Dim A As Variant
A = Split(ActiveDocument.Range.Text, "the")
MsgBox (UBound(A))
End Sub
This creates a array based on a delimiter you specify. After the Split, you display the number of elements with UBound, which is the Upper Boundary of the array.
marcelma
10-11-2010, 07:52 AM
great solution - many thanks.
I wonder how people like you know all such things :-)
fumei
10-12-2010, 09:31 AM
Just remember that that is case-sensitive.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.