在EXCEL中从1~35个数字选5个数字进行排列给合,不能重复,用了公式,但是提示堆栈空间溢出,

我的宏是: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

表示代码在我破电脑的Excel2003上成功运行到正常结束。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2020-11-01
怎么操作的啊
相似回答