Function MeilleureNote(DemClient)
Set f = Sheets("catalogue")
Set dMotsCat = CreateObject("Scripting.Dictionary")
Set dRef = CreateObject("Scripting.Dictionary")
For Each c In f.[B2].Resize(Application.CountA(f.[B:B]))
dRef(CStr(c.Offset(, -1).Value)) = c.Value
For Each m In Split(c.Value, " ")
dMotsCat(m) = dMotsCat(m) & c.Offset(, -1) & " "
Next m
Next c
Set dDemClient = CreateObject("Scripting.Dictionary")
For Each m In Split(DemClient, " ")
If dMotsCat.exists(m) Then
For Each ref In Split(Trim(dMotsCat(m)), " ")
dDemClient(ref) = dDemClient(ref) + 1
Next ref
End If
Next m
'-- recherche maxi dans dDemClient
Maxi = Application.Max(dDemClient.items)
MeilNotePourc = 0
For Each ref In dDemClient.keys
If dDemClient(ref) = Maxi Then
notePourc = Maxi / (UBound(Split(dRef(ref), " ")) + 1)
If notePourc > MeilNotePourc Then
MeilNotePourc = notePourc: RefMeilNote = ref: MeilNote = Maxi & "/" & (UBound(Split(dRef(ref), " ")) + 1)
End If
End If
Next ref
MeilleureNote = RefMeilNote & " (" & MeilNote & ")"
End Function