PDA

View Full Version : Vba scripting dictionary help



bpascal123
07-13-2012, 06:31 PM
Hi,

I'd like to know where I can get resources to understand how works the scripting dictionary. I'm able to use but rather in a blind way (many tries until I find what I want...mixing the difference between items and keys... how it stores data by default? in a vertical way 2 columns n rows or horizontal way because I have seen transpose methods being used with scripting dictionary object.

The example below illustrates one of the things I don't understand, it seems d as a dictionary objects is incremented only if variable city doesn't exist. Is it another way of looping and checking if d(city).exist then blabla?


Set d = New Scripting.Dictionary

For i = 2 To UBound(ka, 1)
city= ka(i, 3)
If Len(city) > 0 Then d(city) = d(city) + 1
Next i

I can get things done using dictionary object but quite in an erractic way.

Thanks if you can help me on this.

Regards,

Pascal Baro

https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)

Admin
07-14-2012, 10:52 AM
Hi Pascal,

Welcome to ExcelFox!!

Have a look at The Dictionary Object (http://msdn.microsoft.com/en-us/library/aa164502(v=office.10).aspx)

and this is the best documentation you would see in net.

Using the Dictionary Class in VBA: Dictionary, Scripting, Microsoft, Visual Basic, Visual Basic for Applications, VB, VBA, Scripting Runtime, Excel, Access, Word, Office (http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/A_3391-Using-the-Dictionary-Class-in-VBA.html)