+ Reply to Thread
Results 1 to 7 of 7

clear or remove collection for further using

  1. #1
    Forum Contributor
    Join Date
    07-13-2015
    Location
    Poland
    MS-Off Ver
    MS Office 365
    Posts
    174

    clear or remove collection for further using

    Hi,

    How can I clear collection or all items inside for use it in next loop?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: clear or remove collection for further using

    Hi zico8,
    try it
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-13-2015
    Location
    Poland
    MS-Off Ver
    MS Office 365
    Posts
    174

    Re: clear or remove collection for further using

    Hi nilem,

    Thanks for replying but it doesn't work.

    I get an error: run-time error '457':
    This key is already associated with an element of this collection

    I think it is still the same collection and I should clear it first. But how?

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: clear or remove collection for further using

    Did you remember to write this line
    Please Login or Register  to view this content.
    Or show please an example of a file in which an error occurs

  5. #5
    Forum Contributor
    Join Date
    07-13-2015
    Location
    Poland
    MS-Off Ver
    MS Office 365
    Posts
    174

    Re: clear or remove collection for further using

    Hi nilem,

    I have checked my code and realized that I had:
    Please Login or Register  to view this content.
    between my loops what caused an error.

    I don't exactly know what is this for but thank you for help.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: clear or remove collection for further using

    It's not clear from your code what you are actually trying to do.

    Why are you using a collection?
    Your code already clears the collection within each interation of k by use of
    Please Login or Register  to view this content.
    What is the point of loop k, it does not appear to change anything during the 5 interations.

    An example workbook containing before and after data sets might help explain to us what you are attempting to do
    Cheers
    Andy
    www.andypope.info

  7. #7
    Forum Contributor
    Join Date
    07-13-2015
    Location
    Poland
    MS-Off Ver
    MS Office 365
    Posts
    174

    Re: clear or remove collection for further using

    I had a mistake in my sample code above.
    It should look like:
    Please Login or Register  to view this content.
    but as I written above I had also On Error line between two loops.
    After deleting it everything works.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Performance of iteration through Words collection degrades as collection gets bigger
    By 6StringJazzer in forum Word Programming / VBA / Macros
    Replies: 7
    Last Post: 01-14-2014, 09:44 AM
  2. Remove duplicates and clear content
    By cokillerliu in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-24-2013, 12:42 AM
  3. Macro or VB to remove or clear checked boxes
    By Marz73 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2012, 11:31 AM
  4. Remove part of a string before adding to New Collection
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-11-2012, 10:03 AM
  5. Replies: 2
    Last Post: 12-23-2011, 11:04 AM
  6. How to empty/clear a collection
    By wotadude in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-30-2009, 03:42 PM
  7. Clear a collection
    By danny2000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2008, 07:14 AM
  8. [SOLVED] Cannot remove item from collection
    By Kou Vang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-31-2006, 04:25 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1