|
练习一下
Sub test()
Dim x As Integer
Dim k As Integer
Dim m, n, i As Integer
Dim sum As Long
Dim ii
Dim arr(1 To 1000, 1 To 3)
Dim brr
Dim crr
k = Range("a1").End(xlDown).Row
For x = 2 To k
m = Range("e" & x).MergeArea.Row
n = Range("e" & x).MergeArea.Count
x = x + n - 1
i = i + 1
arr(i, 1) = m
arr(i, 2) = m + n - 1
Next x
brr = Range("d1:d" & k)
For ii = 1 To UBound(arr)
If arr(ii, 1) <> "" Then
For x = arr(ii, 1) To arr(ii, 2)
sum = sum + brr(x, 1)
Next x
arr(ii, 3) = sum
sum = 0
End If
Next ii
For x = 1 To UBound(arr)
If arr(x, 1) <> "" Then
Range("e" & arr(x, 1)) = arr(x, 3)
End If
Next x
End Sub
|
|