對“20選6”的程式碼程式碼稍作修改即可:從A1-AI1中填充數列 1 2 3 4 5 …… 35然後使用如下宏程式碼:Sub test()
Dim i, j, k, l, m, n As Byte
Dim x As Long, y As Long
Application.ScreenUpdating = False
Range("A2:E65536").ClearContents
x = 2
y = 1
For i = 1 To 35 - 4
For j = i + 1 To 35 - 3
For k = j + 1 To 35 - 2
For l = k + 1 To 35 - 1
For m = l + 1 To 35
Cells(x, y) = Cells(1, i)
Cells(x, y + 1) = Cells(1, j)
Cells(x, y + 2) = Cells(1, k)
Cells(x, y + 3) = Cells(1, l)
Cells(x, y + 4) = Cells(1, m)
x = x + 1
If x > 65536 Then
y = y + 6
End If
Next
Application.ScreenUpdating = True
End Sub
執行結果共有:324632 組
對“20選6”的程式碼程式碼稍作修改即可:從A1-AI1中填充數列 1 2 3 4 5 …… 35然後使用如下宏程式碼:Sub test()
Dim i, j, k, l, m, n As Byte
Dim x As Long, y As Long
Application.ScreenUpdating = False
Range("A2:E65536").ClearContents
x = 2
y = 1
For i = 1 To 35 - 4
For j = i + 1 To 35 - 3
For k = j + 1 To 35 - 2
For l = k + 1 To 35 - 1
For m = l + 1 To 35
Cells(x, y) = Cells(1, i)
Cells(x, y + 1) = Cells(1, j)
Cells(x, y + 2) = Cells(1, k)
Cells(x, y + 3) = Cells(1, l)
Cells(x, y + 4) = Cells(1, m)
x = x + 1
If x > 65536 Then
x = 2
y = y + 6
End If
Next
Next
Next
Next
Next
Application.ScreenUpdating = True
End Sub
執行結果共有:324632 組