Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Jul 2006
    Location
    New York City, New York, USA
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Removing Items from a Collection (2003)

    Hi all,
    I'm playing around with Class Modules for the first time, and was wondering:
    The class I'm using contains data about a worksheet and it's formatting and used range. I've got a number of these new class objects in a collection. I would like to loop through these objects several times. With each loop, some sheets will be determined to have no more problems to be fixed, and should be removed from the collection.
    Is there a simple way to remove these objects from the collection while looping with For Each, or is it best to just use something like For x = colMyCollection.count to 1 step -1 and remove by item number?
    Hope this was clear. Thanks!

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Removing Items from a Collection (2003)

    I think the latter: looping with the item number. I have found that the "each" may get "confused" when things are deleted from (and even added to ) the collection during the looping.

    Steve

  3. #3
    Lounger
    Join Date
    Jul 2006
    Location
    New York City, New York, USA
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing Items from a Collection (2003)

    Thanks, Steve - that makes sense.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •