用函数也可以,但是我们选择用VBA来实现。
在excle中—>Alt+F11—->右击插入—>模块—->然后就可以写代码了—->写完代码后 运行宏(F5)
Sub 求和() Dim i, sum As Integer i = 0 For i = 1 To 9 sum = sum + Sheets(1).Cells(i, 1) Next i Sheets(1).Cells(1, 2) = "1到3的和:" Sheets(1).Cells(2, 3) = sum End Sub
a blog driven by interest~