I am encountering what I think is bizarre behavior in Excel VBA trying to access a dictionary with a non-existent key. Specifically, by requesting the value at that key, the key is automatically added. I have not found this in any of the documentation I could find. Easy to try it:
Sub Test()
Dim d As Scripting.Dictionary
Set d = New Scripting.Dictionary
Debug.Print d.Exists("foo")
Debug.Print d("foo")
Debug.Print d.Exists("foo")
End Sub
False
True
Is this really the expected behavior?