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:
D_Master("Packaging") = D_Master("Packaging") + D_LP("Wrapper")
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?
Dim LP_Range As Range
Set LP_Range = ActiveWorkbook.Sheets("LP to SAP Name Conversion").Range("A8:A4000")
Q = 0
'if the name exists from the definitions create its dict 1 equivalent
For Each Cell In LP_Range 'LP range is the dict 2 location from my worksheet
If D_LP.Exists(CStr(Cell.Value)) Then 'D_LP is my dictionary 2 and D_Master is where I am trying to combine both dictionaries
For Each Key In D_Master
If Key = Cell.Offset(0, 1).Value Then
D_Master(Key) = D_Master(Key) + D_LP(Cell) '<<-- This doesn't seem to be working! Though I get no error
'Following is to see if this is even being executed
Cells(1, 1).Value = "Executed!!!!" 'it is executing this loop
If Q = 0 Then '
Cells(2, 1) = Key 'to make sure it's reading what I expect (I am)
Cells(2, 2) = Cell 'to make sure it's reading what I expect (I am)
Q = 1 'only checking ^^ first entry
End If
End If
Next
End If
Next
'print out
i = 3
For Each Key In D_Master
Range("T" & i).Value = Key
Range("U" & i).Value = D_Master(Key) '<<-- these values are the same as they were in dictionary 1 before running the above code
i = i + 1
Next
Thanks!
Bookmarks