Tag Archives: dictionary

Dictionary in VBA is created with empty key value pair

Questions: After creating a new dictionary: Dim teams as Dictionary Set teams = New Dictionary I noticed that it already contains empty key – value pair (teams.Count returns value of 1). How can I prevent this from happening or delete this pair? Is this normal behaviour? Answers: If you are referencing the same Microsoft Scripting… Read More »

How can I seek key of dictionary by index value?

Questions: How can I get the key of a dictionary by passing the index value? I’m trying: If rs.Fields(“NM”).Value = dictNM.key(0) that is, I want it to compare to the first key in the dictionary but I get the error Compile error: Invalid use of property I tried googling, but to no avail. I’m hoping… Read More »

Fastests way to empty a dictionary into an Excel sheet

Questions: What is the fastest way to empty a Scripting.Dictionary into an excel sheet? This is what I’m doing right now, but for a dictionary with about 3000 elements, it’s noticeably slow. I’ve made every optimization I can think of. Here’s a bare-bones version of what I have: ‘wordCount and emailCount are late bound “Scripting.Dictionary”… Read More »

Excel VBA – Dictonary.Exists(Dictionary)?

Questions: Would like to better understand how keys of object type are compared. dicOverall.exists(dic2) returns False while dicOverall.exists(dic1) returns True. I am not too sure how .Exists compare stuff (loop?) but is there anyway I could get .Exists(dic2) to return True? Thank you! Sub test() Dim dic1 As Object Dim dic2 As Object Dim dicOverall… Read More »