我的建议是,不要做什么按钮了,那还得一个一个去做,直接按Alt+F8执行下面的宏就行了。按Alt+F11,打开VBA编辑器,插入一个模块,把下面的代码贴进去,返回Excel按Alt+F8运行Subtotal即可实现。 可对应收款、未收款进行计算。QQ:99137479
Sub Subtotal()
Dim R As Integer
R = Selection.Row - 1
R1 = Cells(R, 1).End(xlUp).Row
Range(Cells(R + 1, 1), Cells(R + 1, 7)) = Array("小计", "未收款", "已收款", "去零金额", "", "付款方式", "应收款")
Range(Cells(R + 1, 1), Cells(R + 2, 1)).Merge
Range(Cells(R + 1, 1), Cells(R + 2, 7)).HorizontalAlignment = xlCenter
Range(Cells(R + 1, 1), Cells(R + 2, 7)).VerticalAlignment = xlCenter
Range(Cells(R + 1, 4), Cells(R + 2, 5)).Merge True
Cells(R + 2, 6).Validation.Delete
Cells(R + 2, 6).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="现金,挂帐,分期"
Cells(R + 2, 7).FormulaR1C1 = "=SUM(R" & R1 & "C:R[-2]C)"
Cells(R + 2, 2).FormulaR1C1 = "=RC7-RC4-RC3"
End Sub