+ Reply to Thread
Results 1 to 2 of 2

Resize dictionary

  1. #1
    Forum Contributor
    Join Date
    05-30-2013
    Location
    France
    MS-Off Ver
    2010
    Posts
    260

    Resize dictionary

    Hi,

    I have an issue with a dictionary which stores a custom object that is not updating as I thought it would. I have set up the following:
    - a first loop that goes through the keys and pastes the key/value to a worksheet
    - a variable that stores the key name
    - remove the key/value from the dictionary
    - a second loop that compares the variable to the keys adds the value to the same worksheet
    - remove when the keys that were similar to the variable

    The specific issue then is that when I remove the Key/Item in the second loop, the first loop is still iterating through them. Is there a way I can update/resize the dictionary in the second loop ?

    Here's the (messy) code:
    Please Login or Register  to view this content.
    Thanks,
    amphi
    Last edited by amphinomos; 02-04-2016 at 11:21 AM. Reason: code alignment

  2. #2
    Forum Contributor
    Join Date
    05-30-2013
    Location
    France
    MS-Off Ver
    2010
    Posts
    260

    Re: Resize dictionary

    Issue was due to autovivification, by trying to access an non-existing key in a dictionary, VBA will automatically create a blank item.
    Probably not the most elegant but added this to my code before the first loop to skip to the next iteration if the dictionary had a blank key :
    Please Login or Register  to view this content.
    my head hurts now
    Found solution here: http://stackoverflow.com/questions/6910996/scripting-dictionary-lookup-add-if-not-present-with-only-one-key-search
    Last edited by amphinomos; 02-05-2016 at 06:22 AM.

+ 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] How to compare keys in one dictionary to keys in another dictionary
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-15-2015, 02:27 PM
  2. Storing a Dictionary into a Dictionary Object
    By pago_boss in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2015, 03:04 AM
  3. Dictionary - Using a dictionary of dictionaries to hold individual orders
    By wazimu13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-09-2015, 08:32 PM
  4. vba dictionary
    By kieranbop in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2011, 06:06 AM
  5. [SOLVED] I could NOT resize the axis title but excel allows me to resize gr
    By Iwan Setiyono Ko in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-05-2006, 11:50 PM
  6. [SOLVED] I could NOT resize the axis title but excel allows me to resize gr
    By Iwan Setiyono Ko in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-15-2006, 06:40 AM
  7. HELP-Dictionary
    By dfisch8 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2005, 04:05 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