我试图弄清楚,如果这是一个可能性方面的能力的Excel。考虑什么,我试图做下面的代码:是否可以在Excel VBA中将数组字典添加到数组中?
Dim some_text, split_text() As String
Dim some_array_dict() As String 'This is the array to store the dictionaries
Dim some_dict As Dictionary 'The dictionaries that I'll be storing in the array above
ReDim some_array_dict(y) As String 'y is previously defined as an integer
For i = 0 To y - 1
Set some_dict = New Dictionary
some_text = some_array(2, i)
split_text = Split(some_text, " ")
For j = 0 To UBound(split_text)
some_dict.Add split_text(j), 1
Next j
some_array_dict(i) = some_dict 'Issue
Debug.Print some_array_dict(i) 'For debugging purposes
Next i
以下是代码,给我的错误行:
some_array_dict(i) = some_dict
任何人都可以在这方面帮助?让我知道你是否需要任何澄清。
感谢您的帮助。
我觉得Tim的解决方案是唯一一个实际上有效。要小心,因为[Dictionary是一个引用类型](http://stackoverflow.com/questions/3022182/how-do-i-clone-a-dictionary-object),因此将每个数组组件设置为相同的对象将导致相同的对象被所有数组组件引用。我不认为这是你想要的.. – Ioannis
更具体地说,蒂姆的答案,我不得不''昏暗'作为一个'字典'。这实际上最终解决了我面临的问题。感谢帮助! – lcardona89