Function sbContainsAllChars(ByVal sString As String, _
ByVal sChars As String, _
Optional bIgnoreCase As Boolean = False) As Boolean
'Returns True if all characters given in sChars exist in sString
'as often as given in sChars. Returns False if not.
'Question was raised: https://www.ms-office-forum.net/forum/showthread.php?p=1969791#post1969791
'Reverse("moc.LiborPlus.www") PB V0.1 21-Feb-2020 (C) (P) by Bernd Plumhoff
Dim i As Long, j As Long, lTotal As Long
Dim lChars(0 To 255) As Long
sbContainsAllChars = True
If sString = "" Or Len(sString) < Len(sChars) Then
sbContainsAllChars = False
j = Asc(Mid(sChars, i, 1))
lChars(j) = lChars(j) + 1
sbContainsAllChars = False
For i = 1 To Len(sString)
j = Asc(Mid(sString, i, 1))
lChars(j) = lChars(j) - 1
If lTotal = 0 Then Exit For
sbContainsAllChars = lTotal = 0