SoFunction
Updated on 2025-03-02

Function to calculate the number of times a string appears in another string

Function strnum(patrn, strng)
  Dim regEx, Match, Matches,xx
    xx=0
  Set regEx = New RegExp
   = patrn
= True         'Set whether it is case sensitive.
   = True
  Set Matches = (strng)
  For Each Match in Matches
    xx=xx+1
  Next
  strnum = xx
End Function