Sub 按钮1_Click()
Set d = CreateObject("scripting.dictionary")
Set dnm = CreateObject("scripting.dictionary")
arr = [a1].CurrentRegion
For j = 2 To UBound(arr)
d(arr(j, 1)) = d(arr(j, 1)) & "," & j
dnm(arr(j, 1)) = ""
Next j
[f2].Resize(dnm.Count) = WorksheetFunction.Transpose(dnm.keys)
brr = [f1].CurrentRegion
For j = 2 To UBound(brr)
dnm.RemoveAll
crr = Split(d(brr(j, 1)), ",")
For i = 1 To UBound(crr)
dnm(arr(Val(crr(i)), 2)) = ""
brr(j, 3) = brr(j, 3) + arr(Val(crr(i)), 3)
brr(j, 4) = brr(j, 4) + arr(Val(crr(i)), 4)
Next i
brr(j, 2) = Join(dnm.keys, ",")
Next j
[f1].CurrentRegion = brr
End Sub
|