The reason for the code not working is that dic_Ids.Item(ID_array(LC1, 1)) returns a copy of the array and that's what you change. You need to use something like this:
Sub Main()
Dim fl_macro As String
Dim input_fl_last_row As Long
Dim vTemp
fl_macro = ThisWorkbook.Name
Set Input_to_copy = Workbooks(fl_macro).Worksheets("Sheet2")
Set output_sht = Workbooks(fl_macro).Worksheets("Sheet3")
output_sht.Cells.ClearContents
input_fl_last_row = 3689
'create arrays of required header cols
With Input_to_copy
ID_array = .Range(.Cells(1, 1), .Cells(input_fl_last_row, 1)).Value
ProcA_array = .Range(.Cells(1, 2), .Cells(input_fl_last_row, 2)).Value
ProcB_array = .Range(.Cells(1, 3), .Cells(input_fl_last_row, 3)).Value
End With
'create dictionary of SiteId values from input file
Set dic_Ids = CreateObject("scripting.dictionary")
dic_Ids.CompareMode = 1
'
'add items to dictionary.
For LC1 = 2 To UBound(ID_array, 1)
If dic_Ids.Exists(ID_array(LC1, 1)) Then
'these msgbox values are in here to help identify whats going on
MsgBox "in exists " & ID_array(LC1, 1)
MsgBox "current count E is " & dic_Ids.Item(ID_array(LC1, 1))(1)
MsgBox "current count F is " & dic_Ids.Item(ID_array(LC1, 1))(2)
'1st=row of first instance, 2nd will be sum of col B and 3rd will be sum of col C
vTemp = dic_Ids.Item(ID_array(LC1, 1))
vTemp(1) = vTemp(1) + ProcA_array(LC1, 1)
vTemp(2) = vTemp(2) + ProcB_array(LC1, 1)
dic_Ids.Item(ID_array(LC1, 1)) = vTemp
'if item is not in the dictionary then add it and create additional records with it
ElseIf Not dic_Ids.Exists(ID_array(LC1, 1)) Then
'1st=row of first instance, 2nd will be sum of col B and 3rd will be sum of col C
dic_Ids.Item(ID_array(LC1, 1)) = Array(LC1, ProcA_array(LC1, 1), ProcB_array(LC1, 1))
'these msgbox values are in here to help identify whats going on
MsgBox "in NOTTT exists " & ID_array(LC1, 1)
MsgBox "current count E is " & dic_Ids.Item(ID_array(LC1, 1))(1)
MsgBox "current count F is " & dic_Ids.Item(ID_array(LC1, 1))(2)
End If
Next LC1
temp_array = dic_Ids.Items
MsgBox "lkjlk"
End Sub
Bookmarks