|
- Sub test()
- Dim Dic(1 To 2) As Object, Arr, i&, j&, tmPstr$, Trr
- For i = 1 To UBound(Dic)
- Set Dic(i) = CreateObject("scripting.dictionary")
- Next i
- Arr = Sheet2.[a1].CurrentRegion
- For i = 2 To UBound(Arr, 1)
- tmPstr = Arr(i, 1) & Chr(10) & Arr(i, 2)
- Dic(1)(tmPstr) = Dic(1)(tmPstr) + Arr(i, 4)
- Dic(2)(tmPstr) = Dic(1)(tmPstr) + Arr(i, 5)
- Next i
- With Sheet1
- Arr = .[a1].CurrentRegion
- For i = 2 To UBound(Arr, 1)
- tmPstr = Arr(i, 1) & Chr(10) & Arr(i, 2)
- If Dic(1).exists(tmPstr) Then
- Arr(i, 5) = Arr(i, 5) + Dic(1)(tmPstr)
- Arr(i, 6) = Arr(i, 6) + Dic(2)(tmPstr)
- Dic(1).Remove tmPstr: Dic(2).Remove tmPstr
- End If
- Next i
- .[a1].Resize(UBound(Arr, 1), UBound(Arr, 2)) = Arr
-
- If Dic(1).Count Then
- '追补新人
- i = UBound(Arr, 1)
- For Each d In Dic(1).keys
- i = i + 1
- Trr = Split(d, Chr(10))
- .Cells(i, 1) = Trr(0): .Cells(i, 2) = Trr(1)
- .Cells(i, 5) = Dic(1)(d): .Cells(i, 6) = Dic(2)(d)
- Next d
- End If
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|