The following macro will count the unique occurrences of each character in a string thus
Lorem will have five unique characters and
Lorem ipsum will have ten unique characters (including the space). mummy will have three unique characters.
Code:
Sub CountUniqueChars()
Dim Col As Collection
Dim oRng As Range
Dim i As Integer
If Len(Selection.Range) > 0 Then
Set oRng = Selection.Range
Set Col = New Collection
On Error Resume Next
For i = 1 To Len(oRng)
Col.Add Mid(oRng.Text, i, 1), Mid(oRng.Text, i, 1)
Next i
MsgBox Col.Count
Else
MsgBox "Nothing selected"
End If
lbl_Exit:
Set Col = Nothing
Exit Sub
End Sub