|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub text()
Dim arr, brr, crr
Dim x, i
Dim dic, key
Set dic = CreateObject("scripting.dictionary")
arr = Sheets(1).UsedRange
ReDim crr(1 To UBound(arr), 1 To 7)
For x = 2 To UBound(arr)
key = arr(x, 7) & "|" & arr(x, 8)
If Not dic.exists(key) Then
dic(key) = dic.Count + 1
crr(dic(key), 1) = arr(x, 7)
crr(dic(key), 2) = arr(x, 8)
crr(dic(key), 3) = arr(x, 9)
crr(dic(key), 4) = arr(x, 10)
crr(dic(key), 5) = arr(x, 11)
Else
crr(dic(key), 5) = crr(dic(key), 5) + arr(x, 11)
End If
Next
brr = Sheets(2).UsedRange
For i = 2 To UBound(brr)
key = brr(i, 7) & "|" & brr(i, 8)
crr(dic(key), 6) = crr(dic(key), 6) + brr(i, 11)
crr(dic(key), 7) = crr(dic(key), 5) - crr(dic(key), 6)
Next
Sheets(3).[a5].Resize(dic.Count, 7) = crr
End Sub
|
|