
试下
Sub 条件求和()
ActiveCellFormulaR1C1 = "=SUMIF(C[-4],RC[-1],C[-3])"
Range("O3")Select
SelectionAutoFill Destination:=Range("O3:O5"), Type:=xlFillDefault
Range("O3:O5")Select
Selectioncopy
SelectionPasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ApplicationCutCopyMode = False
End Sub
就这么简单!
sub Test()dim i as integer
for i=2 to [A65536]end(xlup)row
cells(i,3)=cells(i,2)+cells(i,1)
next
end sub
Sub 求和()
For i = 1 To [b65536]End(3)Row
Cells(i, "q") = ApplicationSum(Range("b" & i & ":o" & i))
Cells(i, "r") = ApplicationAverage(Range("b" & i & ":o" & i))
Next
End Sub
'从B列第一行开始逐个统计,结果显示在C列
Sub tj()
For r = 1 To Range("B65536")End(xlUp)Row
Dim a
a = Cells(r, 2)
Dim n
n = Len(a)
Dim x As Integer
For i = 1 To n
x = x + Mid(a, i, 1)
Next
Cells(r, 3) = x
x = 0
Next
End Sub
以上就是关于excel用vba求一组数列的和全部的内容,包括:excel用vba求一组数列的和、如何用VBA编写两列数据的和、excel vba 怎么求平均值,求和等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)