Public Type aa: index As Long: item As String: End Type
Public Type Dico: items() As Variant: keys() As Variant: keyVal() As aa: Count As Long
End Type
Sub test()
Dim D As Dico
tabl = [A1:B10].Value
ReDim Preserve D.keyVal(1 To Application.Max([A1:A10]))
ReDim Preserve D.keys(1 To UBound(tabl))
ReDim Preserve D.items(1 To UBound(tabl))
For i = 1 To UBound(tabl)
With D.keyVal(tabl(i, 1)):
.item = .item & " |" & tabl(i, 2)
If .index = 0 Then a = a + 1: .index = a:
D.keys(.index) = tabl(i, 1)
D.items(.index) = .item
End With
Next
ReDim Preserve D.keys(1 To a)
ReDim Preserve D.items(1 To a)
D.Count = a
MsgBox "nombre d'element dans le dico : " & D.Count & vbCrLf & _
" les clés " & vbCrLf & Join(D.keys, vbCrLf) & vbCrLf & _
" les items " & vbCrLf & Join(D.items, vbCrLf)
MsgBox "pour 23 par exemple les valeurs sont " & vbCrLf & D.keyVal(23).item
End Sub