Hello all,
I have a dictionary from sheet 1. Im checking sheet 2 (Col W) with the first 2 parts of the key from the dictionary.
if the key exists, populate an array of counts for each type, per key.
In the end i would just like to output them to a sheet 3.
Problem:
The counts are not populating. in any of the debug statements, they are coming up blank.... Can anyone spot where I'm messing up?
I have a dictionary from sheet 1. Im checking sheet 2 (Col W) with the first 2 parts of the key from the dictionary.
if the key exists, populate an array of counts for each type, per key.
In the end i would just like to output them to a sheet 3.
Problem:
The counts are not populating. in any of the debug statements, they are coming up blank.... Can anyone spot where I'm messing up?
VBA Code:
Dim data2 As Variant
data2 = Sheets("Sheet2").Range("W1:W" & Sheets("Sheet2").Cells(Rows.Count, "W").End(xlUp).Row).value
Dim key As String
Dim value As String
Dim counts() As Long
For i = 2 To UBound(data2, 1)
key = ""
value = ""
counts = Array(0, 0, 0, 0, 0)
arr = Split(data2(i, 1), "|")
key = arr(0) & "|" & arr(1)
value = arr(2)
If dict.Exists(key) Then
counts = dict.Item(key)
Debug.Print "Before update: key=" & key & ", value=" & value & ", counts=" & Join(counts, ", ")
Select Case value
Case "1-Emergency"
counts(0) = counts(0) + 1
Case "3A - High Sustain"
counts(1) = counts(1) + 1
Case "3B - Medium Sustain"
counts(2) = counts(2) + 1
Case "4A - High Enhance"
counts(3) = counts(3) + 1
Case "Type 5"
counts(4) = counts(4) + 1
End Select
Debug.Print "After update: key=" & key & ", value=" & value & ", counts=" & Join(counts, ", ")
dict.Item(key) = counts
Debug.Print "After dict update: key=" & key & ", counts=" & Join(dict.Item(key), ", ")
End If
Next i