Reputation: 53
How do I stop overwriting my string "finalString" and appending to it instead. I want for each w in D(V) to be one string before going to next w.
I = 1
x = 1
For Each V In D.keys
Ws.Cells(I, 4) = V
I = I + 1
For Each w In D(V)
finalString = w
Ws.Cells(x, 5) = finalString
Next w
x = x + 1
Next V
Stop
Upvotes: 0
Views: 52
Reputation: 42236
Try one single line of code:
Ws.Cells(x, 5) = Join(dict.Keys, "")
To retrieve all PARTIAL concatenated keys:
Dim arr as Variant, i as long
arr = dict.Keys
k = dict.count - 1
For i = UBound(arr) To 0 Step -1
ReDim Preserve arr(k): k = k - 1
Debug.Print Join(arr, "")
Next i
Upvotes: 1
Reputation: 171
try using +=
that will append all values to the righ of the current finalString
UPDATE:
My mistake. In VBA is different should be finalString = finalString & w
my apologies
Upvotes: 2