Gruppe
UDF
Problem
Wie kann ich ermitteln, wie oft ein bestimmtes Zeichen oder auch eine Zeichenfolge in einem bestimmten Bereich vorkommt?
StandardModule: basMain
Function CharCount( _
rng As Range, _
sChr As String, _
bln As Boolean)
Dim rngAct As Range
Dim iCounter As Integer, iChr As Integer
For Each rngAct In rng.Cells
If InStr(rngAct.Value, sChr) Then
If bln = False Then
iCounter = iCounter + 1
Else
For iChr = 1 To Len(rngAct.Value)
If Mid(rngAct.Value, iChr, Len(sChr)) = sChr Then
iCounter = iCounter + 1
End If
Next iChr
End If
End If
Next rngAct
CharCount = iCounter
End Function