Please, use the next function:
Function ex_dictX(rng As Range) As String
Dim dict As Object, i As Long, j As Long, arr, strIt As String
Set dict = CreateObject("Scripting.Dictionary")
arr = rng.Value2: strIt = "["
For i = 1 To UBound(arr, 2)
For j = 2 To UBound(arr)
strIt = strIt & arr(j, i) & ","
Next j
dict.Add Chr(34) & arr(1, i) & Chr(34) & ": ", left(strIt, Len(strIt) - 1) & "]"
strIt = "["
Next i
'build the string to be returned (as pseudo dictionary):
For i = 0 To dict.count - 1
strIt = strIt & dict.Keys()(i) & dict.items()(i) & ", "
Next
ex_dictX = "{" & left(strIt, Len(strIt) - 2) & "}"
End Function
It can be tested with a simple Sub:
Sub tesTex_dict()
Debug.Print ex_dict(Range("A1:B4"))
End Sub
or call it as UDF (User Defined Function) from a cell as:
=ex_dict(A1:B4)
Edited:
Please, test the next version which returns a Scripting.Dictionary:
Function ex_dictD(rng As Range) As Object
Dim dict As Object, i As Long, j As Long, arr, strIt As String
Set dict = CreateObject("Scripting.Dictionary")
arr = rng.Value2: strIt = "["
For i = 1 To UBound(arr, 2)
For j = 2 To UBound(arr)
strIt = strIt & arr(j, i) & ","
Next j
dict.Add Chr(34) & arr(1, i) & Chr(34), left(strIt, Len(strIt) - 1) & "]"
strIt = "["
Next i
Set ex_dictD = dict
End Function
It can be tested in a Sub like the following one:
Sub testEx_dict()
Dim dict As Object, i As Long
Set dict = ex_dictD(Range("A1:C4"))
For i = 0 To dict.count - 1
Debug.Print dict.Keys()(i) & " = " & dict.items()(i)
Next
End Sub