+ Reply to Thread
Results 1 to 6 of 6

Dictionary Value not being updated

  1. #1
    Registered User
    Join Date
    07-30-2014
    Location
    Frederick, Maryland
    MS-Off Ver
    Professional Plus 2010
    Posts
    12

    Dictionary Value not being updated

    I have 2 dictionaries; both have a "location" and the "frequency of occurence". The 2nd dictionary locations are related to the first, but are named differently, so I have a range of cells I'm using to define the equivalent locations, ie:

    Dict. 2 Location----Dict. 1 Location
    Wrapper------------Packaging
    Robot----------------Robot Arm
    Robot----------------Robot Base
    etc..

    (It's not a direct 1 for 1)

    The program is meant to take both dictionaries, convert the 2nd dictionary keys to the equivalent dictionary 1 keys (based on the cell range data provided) and then combine the values associated with that location and store them in D_Master.
    D_Master is a copy of my dictionary 1, in which I am also trying to add the values from dictionary 2.

    I started by writing the location definitions within the program, ie:
    Please Login or Register  to view this content.
    which works, but there are several hundred definitions and it becomes less robust, whereas a user could type in a definition within the range of cells and the code below could take care of the rest.

    What am I doing wrong?

    Please Login or Register  to view this content.
    Thanks!

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Dictionary Value not being updated

    You are not using the key (Cell.Value)) ) to load what ever the data in to items

    Please Login or Register  to view this content.
    is correct, then, what do you want to do with the key. You want to assign (write data in items using a key)

    For example. D_LP.Item(CStr(Cell.Value)) = D_Master(Key) + D_LP(Cell)

    This is not complete code. With out seeing the entire code, it is difficult to comment.

  3. #3
    Registered User
    Join Date
    07-30-2014
    Location
    Frederick, Maryland
    MS-Off Ver
    Professional Plus 2010
    Posts
    12

    Re: Dictionary Value not being updated

    I know, unfortunately I don't think the rest of the code would help much without posting the workbook as well, which I don't think I'm at liberty to post.
    I'm not sure I fully understood what you meant but the form in my code is the same as how I mentioned I did it previously - by defining it within the code explicitly.
    aka D_Master("Packaging") = D_Master("Packaging") + D_LP("Wrapper")

    To me , my following code reads:
    "For each dictionary 2 location (defined by user), if it exists (as a key) in dictionary 2, and if there is a key in dictionary 1 that matches the corresponding dictionary 1 location (defined by user), then add their occurence counts together."

    The D_Master(Key) refers to the user defined cell next to "Cell" that is currently being tested.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Dictionary Value not being updated

    This appears to me to be looping through a range
    For Each Key In D_Master
    Where is the dictionary or key on these range?

  5. #5
    Registered User
    Join Date
    07-30-2014
    Location
    Frederick, Maryland
    MS-Off Ver
    Professional Plus 2010
    Posts
    12

    Re: Dictionary Value not being updated

    It is - the range is a user input for defining equivalent location definitions.

    ie:
    Dictionary 2 Location Dictionary 1 Location Equivalent
    #1 Robot R1 Robot
    Wrapper Packaging

    The keys for the dictionaries have already been defined from another set of data - some of which should match up with this range.

    So for my example above, I'd be attempting to take the occurances (value) of dictionary 2 key "#1 Robot" and add them to the dictionary 1 key "R1 Robot"

  6. #6
    Registered User
    Join Date
    07-30-2014
    Location
    Frederick, Maryland
    MS-Off Ver
    Professional Plus 2010
    Posts
    12

    Re: Dictionary Value not being updated

    Bump - No Answer

    I've tried multiple other ways to try to get the values and comparisons I need but to no avail. Any other route ideas would also be appreciated.

+ 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. vba dictionary
    By kieranbop in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2011, 06:06 AM
  2. Updated Links dont remember they're updated
    By carsto in forum Excel General
    Replies: 0
    Last Post: 05-05-2009, 11:26 AM
  3. Rev. Auto Updated when sheet is updated and or entire book
    By frankee_gee in forum Excel General
    Replies: 1
    Last Post: 04-07-2008, 05:05 PM
  4. HELP-Dictionary
    By dfisch8 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-22-2005, 04:05 PM
  5. [SOLVED] Dictionary
    By Jac Tremblay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-22-2005, 04:06 PM

Tags for this Thread

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