
问题如下:
例如:给出20个数字(1、2、3、4、5、6、7、8、9、10、11、12、13、14、15、16、17、18、19、20)来组合6个数为一组的组合:例如:1、2、3、4、5、6。请问Excel表怎样可以自动组合出所有组合数的组合明细啊(既每组有哪六个数组合)
Sub a()
Dim a%, b%, c%, d%, e%, f%, g%, i&
i = 2
For a = 1 To 20
For b = a + 1 To 20
For c = b + 1 To 20
巧哪 For d = c + 1 To 20
For e = d + 1 To 20
For f = e + 1 To 20
Cells(i, 1) = Cells(1, a)
Cells(i, 2) = Cells(1, b)
Cells(i, 3) = Cells(1, c)
Cells(i, 4) = Cells(1, d)
Cells(i, 5) = Cells(1, e)
Cells(i, 6) = Cells(1, f)
i = i 简困+ 1
孝咐码 Next f
Next e
Next d
Next c
Next b
Next a
End Sub
A1――T1存放你的20个数
速度有点慢。。。。。
右键SHEET1(工作表标签),查看代码。粘贴上面的代码。运行。