2016-10-04 156 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