
dim arr, i as integer,he as integer
arr=[a3:b11]
for i=1 to ubound(arr)
if arr(i,1)="1001" or arr(i,1)="1003" then
he=he+arr(i,2)
end if
next
[b12]=he
end sub
第二个
Sub 阶乘()
Dim i As Integer, a As Integer, jc As Integer
a = [a1]
jc = 1
For i = 1 To a
jc = jc * i
Next
[a2] = jc
End Sub
在A1单元格输入整数,在B1单元格输出结果:
Sub 阶乘()Dim s As Long, n As Integer, i As Integer
n = Val(Range("A1").Value)
s = 1
For i = 1 To n
s = s * i
Next i
Range("B1").Value = s
End Sub
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)