excel:在1-30中,任选6个彼此不同的数进行组合,如何列出所有的组合
如1,2,4,11,15,26,27,这样,由6个不大于30的数字组成,并且内部没有重复的数字组合应该有几十万个组合来着。怎么弄出这些数组?...
如1,2,4,11,15,26,27,这样,由6个不大于30的数字组成,并且内部没有重复的数字组合
应该有几十万个组合来着。怎么弄出这些数组? 展开
应该有几十万个组合来着。怎么弄出这些数组? 展开
2个回答
展开全部
Sub 列出全任意30选6组合()
Application.ScreenUpdating = False
ww = 2
For m1 = 1 To 25
For m2 = m1 + 1 To 26
For m3 = m2 + 1 To 27
For m4 = m3 + 1 To 28
For m5 = m4 + 1 To 29
For m6 = m5 + 1 To 30
Cells(ww, 1).Value = m1
Cells(ww, 2).Value = m2
Cells(ww, 3).Value = m3
Cells(ww, 4).Value = m4
Cells(ww, 5).Value = m5
Cells(ww, 6).Value = m6
ww = ww + 1
Next
Next
Next
Next
Next
Next
Application.ScreenUpdating = True
End Sub
别忘了给分啊!
Application.ScreenUpdating = False
ww = 2
For m1 = 1 To 25
For m2 = m1 + 1 To 26
For m3 = m2 + 1 To 27
For m4 = m3 + 1 To 28
For m5 = m4 + 1 To 29
For m6 = m5 + 1 To 30
Cells(ww, 1).Value = m1
Cells(ww, 2).Value = m2
Cells(ww, 3).Value = m3
Cells(ww, 4).Value = m4
Cells(ww, 5).Value = m5
Cells(ww, 6).Value = m6
ww = ww + 1
Next
Next
Next
Next
Next
Next
Application.ScreenUpdating = True
End Sub
别忘了给分啊!
追问
看来遇到大师级的了。不过你这个好像是编程来着。怎么在excel里弄?感激。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询