Harry Flashman
Active Member
- Joined
- May 1, 2011
- Messages
- 361
How can I check if an item exist within a New Collection?
I have a routine which put unique cell values into a new collection if those cells values meet a particular criteria. This works well. I can output the collection values on another worksheet fine.
The object variable MyRng4 refers to a column of data
NewColl is the name for my New Colleciton
After I put these items into my collection, I now want to loop back through my range and delete all the rows where the cell value is NOT in the collection.
I realize I could probably pass my collection into an array and then check to see if the item is within that array - but I feel there must be away to check if a string is in a New Collection, and if there is way I would like to learn that method.
Any help would be greatly appreciated. Cheers.
I have a routine which put unique cell values into a new collection if those cells values meet a particular criteria. This works well. I can output the collection values on another worksheet fine.
The object variable MyRng4 refers to a column of data
NewColl is the name for my New Colleciton
Code:
On Error Resume Next
For Each MyCell In MyRng4.Cells
If MyCell.Offset(0, -1).Value = strBrandLimit Then
NewColl.Add MyCell.Value, CStr(MyCell.Value)
End If
Next MyCell
After I put these items into my collection, I now want to loop back through my range and delete all the rows where the cell value is NOT in the collection.
I realize I could probably pass my collection into an array and then check to see if the item is within that array - but I feel there must be away to check if a string is in a New Collection, and if there is way I would like to learn that method.
Any help would be greatly appreciated. Cheers.
Last edited: