2016-10-04 155 views
0

我有一个集合的集合。内部集合保存字符串项目。循环集合集合

灌装内收集:

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 
+0

有一个固定的时间段,你不能接受你自己的答案!我认为这是两天左右。 – ruedi