I'm currently trying to add a collection I made to an array of collections. It keeps throwing errors when I go to add my collection to an array of collections I made. The collection is being added to array in the second for loop near the bottom. Maybe I declared it wrong or its just not possible to create an array of collections. I wasn't given any errors when declaring one so, idk. Any ideas?
Update: The error it is giving me is Object variable or With block variable not set. I am trying to to add a collection I made to an array of collections
Update2: Changed some code based on suggestions. Currently trying to figure out how to access Collection stored in array of Collection
Private Sub CommandButton2_Click()
Dim currentWorksheet As Worksheet
WS_Count = ActiveWorkbook.Worksheets.Count
Dim rows As Integer
rows = WS_Count - 3
Dim itemsFoundList() As String
Dim itemsSold() As Integer
Dim numItems As String
Dim counter As Integer
Dim d As Integer
Dim masterArray() As Collection
ReDim masterArray(0 To WS_Count)
Dim itemList As Collection
counter = 1
d = 1
For i = 3 To WS_Count - 1
Set currentWorksheet = ActiveWorkbook.Worksheets(i)
Set itemList = New Collection
numItems = numberOfItems(currentWorksheet, "Drink", "I2", "I18")
' MsgBox " " & numItems
ReDim itemsFoundList(0 To CInt(numItems))
ReDim itemsSold(0 To CInt(numItems))
itemsFoundList = itemsFound(currentWorksheet, "Drink", "I2", "I18", CInt(numItems), "A")
itemsSold = itemsSoldFound(currentWorksheet, "Drink", "I2", "I18", CInt(numItems), "E")
itemList.Add itemsFoundList
itemList.Add itemsSold
itemList.Add currentWorksheet.Name
Set masterArray(counter) = itemList
'How to access Collection stored in Array of Collections?'
counter = counter + 1
Next i
End Sub