自己百度了下,后面还是自己写了
Private Sub CommandButton1_Click()
Dim arr, i, n, s
arr = Range("B1:D" & Range("c65536").End(xlUp).Row
n = 1 '存每个合并单元格的第一行
s = 0 '存求和结果
For i = 1 To UBound(arr)
s = s + arr(i, 2)
If arr(i, 1) <> "" Then '当新遇见B列的不为空的行,相当于下个单元时候处理上个单元的和
arr(n, 3) = s - arr(i, 2)
n = i
s = arr(i, 2)
End If
Next
arr(n, 3) = s
Range("B1:D" & Range("c65536").End(xlUp).Row) = ar
End Sub