这样用excel把组合数列出来。我要在1-15中选5个数,把所有可能列出来,不需要排列。
2个回答
展开全部
会用Excel VBA吗?
下面代码可列出所有可能
Sub 组合5in15()
Dim I1, I2, I3, I4, I5, M
M = 0
For I1 = 1 To 11
For I2 = I1 + 1 To 12
For I3 = I2 + 1 To 13
For I4 = I3 + 1 To 14
For I5 = I4 + 1 To 15
M = M + 1
Range("A" & M) = I1: Range("B" & M) = I2: Range("C" & M) = I3: Range("D" & M) = I4: Range("E" & M) = I5
Next
Next
Next
Next
Next
End Sub
下面代码可列出所有可能
Sub 组合5in15()
Dim I1, I2, I3, I4, I5, M
M = 0
For I1 = 1 To 11
For I2 = I1 + 1 To 12
For I3 = I2 + 1 To 13
For I4 = I3 + 1 To 14
For I5 = I4 + 1 To 15
M = M + 1
Range("A" & M) = I1: Range("B" & M) = I2: Range("C" & M) = I3: Range("D" & M) = I4: Range("E" & M) = I5
Next
Next
Next
Next
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询