我有一系列收藏品。内部集合包含字符串项。
填充内部收藏:
Function collect_excellent_Companies(ByVal folderName As String, ByVal fileName As String) As Collection
..
Do While .Cells(countGreens, 1).Interior.Color = 65280
myCol.Add CStr(.Cells(countGreens, 4).Value2)
countGreens = countGreens + 1
Loop
...
End Function
填写外部馆藏:
For iRow = 1 To LastRow
param1 = .Cells(iRow, 1).Value2 + "-Info"
param2 = .Cells(iRow, 1).Value2
fullCollection.Add collect_excellent_Companies(param1, param2)
Next iRow
现在我想用
循环外部和内部集合Dim sepCol As Collection
Set sepCol = New Collection
Dim tmpCol As Collection
Set tmpCol = New Collection
Dim myStr As Object
'Loop over each competion
For Each sepCol In myCol
For Each myStr In sepCol
tmpCol.Add myStr
Next myStr
next sepCol
我已经在这个循环之前检查了集合的内容,这一切都没问题。我得到的错误在于:
For each myStr in sepCol
Runtime Error 424: Object necessary.
我已将Dim myStr as String
更改为D im myStr as Object
,但这无济于事。任何想法我得到这个工作的人都会非常欢迎!
答案 0 :(得分:1)
我自己找到了解决方案。
我必须设置
Dim myStr as Variant