So, i have been introduced to dictionary's so thought i would have a play...
What i would like to do is add 'ref' as a key and assign "Sheets(2).Cells(row.row, TotalClaimCol).Value" value to this key.
To avoid duplicates i have added if statement to check if exists
When i run this code i get an error saying the item already exists.
Any help would be appreciated, also can you assign multiple items too one key?
Cheers
What i would like to do is add 'ref' as a key and assign "Sheets(2).Cells(row.row, TotalClaimCol).Value" value to this key.
To avoid duplicates i have added if statement to check if exists
When i run this code i get an error saying the item already exists.
Any help would be appreciated, also can you assign multiple items too one key?
Cheers
Code:
For Each row In [kam_data[claimsent]].Rows
If CLng(row.Value) < startdate Then
Ref = Sheets(2).Cells(row.row, RefCol).Value
FoundMatch = False
' Has item been added yet?
If dict.Exists(Ref) Then
End If
' add item
Else
dict.Add Ref, Sheets(2).Cells(row.row, TotalClaimCol).Value
End If
' total items
Dim item As Variant
For Each item In dict.Items
TotalClaimAmnt = TotalClaimAmnt + item
Next item
next