I wrote a function which create a dictionary and have faced with strange behavior: I can retrieve value by key only inside function. When i try to do it with dictionary returned by function, I receive Run-time error '450'
My code is:
Option Explicit
Function year_range_dict() As Object
Dim d
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "aaa"
d.Add "b", "bbb"
d.Add "c", "ccc"
If d.Exists("c") Then
MsgBox d("c")
End If
Set year_range_dict = d
End Function
Sub DefaultRates()
MsgBox year_range_dict()("a"), "outside of function"
End Sub
When this code is run, I receive message box with "CCC" and then error message
