作者:乔山办公网日期:
返回目录:excel表格制作
Sub xx()
arr = [v1:w12] '在这里修改
For i = 1 To UBound(arr, 1)
Cells(i, 24) = (arr(i, 1) + arr(i, 2)) Mod 10
Next
End Sub
举例:知道B1公式内:=sum(a1:a5)
VBA写法容:
Sub iSum()
Dim c As Range, s, tmp
s= 0
For Each c In Range("A1:A5")
tmp = c
If IsNumeric(tmp) Then s = s + tmp
Next
Range("B1") = s
End Sub
直接公式不就好么 ,要VBA 作甚
[a1] =application.sum(range("A2:A" & cells(rows.count ,1 ).end(xlup).row))
VBA没有这样的函数,可以使用worksheetfunction.sum调用工作表函数