你好!Excel 中20个数字的任意5个数字排列组合怎样做。 比如1,2,3,4,5或者1,2,3,4,5,20等等

2024-11-01 19:34:14
推荐回答(2个)
回答1:

下面程序只算出组合,没有排列
Sub 组合5in20()
Dim I1, I2, I3, I4, I5, M
M = 0

For I1 = 1 To 16
For I2 = I1 + 1 To 17
For I3 = I2 + 1 To 18
For I4 = I3 + 1 To 19
For I5 = I4 + 1 To 20
M = M + 1
Range("A" & M) = I1: Range("B" & M) = I2: Range("C" & M) = I3: Range("D" & M) = I4: Range("E" & M) = I5
Next
Next
Next
Next
Next
End Sub

回答2:

用VBA吧。