|
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Set d = CreateObject("scripting.dictionary")
For j = 2 To Sheets.Count
For l = 2 To Sheets(j).Cells(Rows.Count, 1).End(3).Row
y = Sheets(j).Cells(l, 1) & "-" & Sheets(j).Cells(l, 2)
If d.exists(y) Then
arr = Split(d(y), "-")
str1 = Val(arr(0)) + Sheets(j).Cells(l, 3)
For i = 4 To 12
str1 = str1 & "-" & (Val(arr(i - 3)) + Sheets(j).Cells(l, i))
Next i
d(y) = str1
str1 = ""
Else
str1 = Sheets(j).Cells(l, 3)
For i = 4 To 12
str1 = str1 & "-" & Sheets(j).Cells(l, i)
Next i
d(y) = str1
str1 = ""
End If
Next l
Next j
arr1 = d.keys
i = d.Count
arr2 = d.items
For j = 0 To UBound(arr1)
Range("a" & j + 2 & ":b" & j + 2) = Split(arr1(j), "-")
Range("c" & j + 2 & ":l" & j + 2) = Split(arr2(j), "-")
Next j
Application.ScreenUpdating = True
End Sub
|
|