'数据太少,供参考,,,
Option Explicit
Sub test()
Dim arr, brr(20), i, j, p, t
arr = Range("a2:b" & [a2].End(xlDown).Row)
For i = UBound(arr, 1) To 1 Step -1
t = Split(arr(i, 1), ".")
If p = 0 Then
p = UBound(t): brr(p) = arr(i, 2)
brr(0) = brr(0) + arr(i, 2)
Else
If UBound(t) = p Then
brr(p) = brr(p) + arr(i, 2)
brr(0) = brr(0) + arr(i, 2)
Else
If UBound(t) < p Then
arr(i, 2) = brr(p)
If UBound(t) > 0 Then brr(UBound(t)) = brr(p)
Else
brr(UBound(t)) = arr(i, 2)
brr(0) = brr(0) + arr(i, 2)
End If
p = UBound(t)
End If
End If
If UBound(t) = 0 Then arr(i, 2) = brr(0): brr(0) = 0: p = 0
Next
[e2].Resize(UBound(arr, 1), 2) = arr
End Sub |