Sub AnalyseTexte()
'utilise UCase pour que la casse ne soit pas prise en compte
Dim txt$, mes$, d As Object, i%, c$, j%, n%
txt = InputBox("Entrer le texte à analyser :", "Analyser")
If txt = "" Then Exit Sub
mes = "Il n'est pas tenu compte de la casse" & vbLf & vbLf & _
"Texte analysé : " & txt & vbLf
Set d = CreateObject("Scripting.Dictionary")
For i = 1 To Len(txt)
c = Mid(txt, i, 1)
If c <> " " And Not d.Exists(UCase(c)) Then
d(UCase(c)) = UCase(c)
n = 0
For j = i To Len(txt)
If UCase(Mid(txt, j, 1)) = UCase(c) Then n = n + 1
Next
mes = mes & vbLf & c & " = " & n
End If
Next
MsgBox mes, , "Analyse"
End Sub