我正在尝试根据可能的类别列表将项目分类为几个数组。现在,我已经设法将一个类别与两个数组中的每个项目相关联,但是现在我想将它们重新分组,以使它们与类别中的其他项目成组。
我被困住了,因为我创建了一个要用作新集合名称的唯一项列表。在我看来,这需要一个循环,但我知道在循环中创建变量总是不被接受。另外,它不起作用。这是现在的代码:
For i = 1 To UBound(ItemList1)
For j = 1 To UBound(MasterList, 2)
check = ItemList1(i) Like MasterList(3, j)
If check Then
ItemList1Categories(i) = MasterList(8, j)
End If
Next
Next 'Creates first array of categories
For i = 1 To UBound(ItemList2)
For j = 1 To UBound(MasterList, 2)
check4 = ItemList2(i) Like MasterList(3, j)
If check4 Then
ItemList2Categories(i) = MasterList(8, j)
End If
Next
Next 'Creates second array of categories
On Error Resume Next
For Each a In ItemList1Categories
Categories.Add a, a
Next 'Stores unique items from first array of categories to collection
On Error Resume Next
For Each a In ItemList2Categories
Categories.Add a, a
Next 'Adds unique items from second array of categories to collection
'This part is bad and I would appreciate some help
For i = 1 To Categories.Count
Set Categories(i) = New Collection
Next