excel用函数求组合,如1,2,3,4,5,6,7,8,9,10任选6个数字进行组合且把这些组合数全部列出来?
问题描述:
excel用函数求组合,如1,2,3,4,5,6,7,8,9,10任选6个数字进行组合且把这些组合数全部列出来?
就是从上面十个数字中任意选六个出来相组合啊,并且列出相关的组合,用excel能实现吧?
答
宏:
Sub xx()
r = 1
For a = 1 To 5
For b = a + 1 To 6
For c = b + 1 To 7
For d = c + 1 To 8
For e = d + 1 To 9
For f = e + 1 To 10
Cells(r,1) = a
Cells(r,2) = b
Cells(r,3) = c
Cells(r,4) = d
Cells(r,5) = e
Cells(r,6) = f
r = r + 1
Next f,e,d,c,b,a
End Sub