有1 2 3 4 5 五个数 如何用EXCEL求任意3个数之积的和(3个数的组合不重复),任意4个数积之和等等
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 07:50:24
有1 2 3 4 5 五个数 如何用EXCEL求任意3个数之积的和(3个数的组合不重复),任意4个数积之和等等
有1 2 3 4 5 五个数 如何用EXCEL求任意3个数之积的和(3个数的组合不重复),任意4个数积之和等等
有1 2 3 4 5 五个数 如何用EXCEL求任意3个数之积的和(3个数的组合不重复),任意4个数积之和等等
用VBA可做,把任意5个数放在A1:A5
任意3个数之积的和
Sub S3()
Dim i1 As Integer,i2 As Integer,i3 As Integer
Dim s As Integer
s = 0
For i1 = 1 To 3
For i2 = i1 + 1 To 4
For i3 = i2 + 1 To 5
s = s + Range("A" & i1) * Range("A" & i2) * Range("A" & i3)
Next i3
Next i2
Next i1
MsgBox ("S=" & s)
End Sub
任意4个数之积的和
Sub S4()
Dim i1 As Integer,i2 As Integer,i3 As Integer,i4 As Integer
Dim s As Integer
s = 0
For i1 = 1 To 2
For i2 = i1 + 1 To 3
For i3 = i2 + 1 To 4
For i4 = i3 + 1 To 5
s = s + Range("A" & i1) * Range("A" & i2) * Range("A" & i3) * Range("A" & i4)
Next i4
Next i3
Next i2
Next i1
MsgBox ("S=" & s)
End Sub