展开全部
Sub sum350()
Dim j(1 To 10) As Integer
Dim k(1 To 10) As Integer
For i = 1 To 10
j(i) = Cells(i, 1)
Next
For k1 = 0 To j(1) Step j(1)
For k2 = 0 To j(2) Step j(2)
For k3 = 0 To j(3) Step j(3)
For k4 = 0 To j(4) Step j(4)
For k5 = 0 To j(5) Step j(5)
For k6 = 0 To j(6) Step j(6)
For k7 = 0 To j(7) Step j(7)
For k8 = 0 To j(8) Step j(8)
For k9 = 0 To j(9) Step j(9)
For k10 = 0 To j(10) Step j(10)
If k1 + k2 + k3 + k4 + k5 + k6 + k7 + k8 + k9 + k10 = 350 Then
Debug.Print k1, k2, k3, k4, k5, k6, k7, k8, k9, k10
End If
Next k10, k9, k8, k7, k6, k5, k4, k3, k2, k1
End Sub
'测试成功,数据放在A1到A10里
然后运行这个程序
测试结果,每个横排的数字加一起都是350
测试结果显示在立即窗口快捷键Ctrl+G
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询