1-13个数字中 选5个不同的组合 怎样在EXCEL中用公式将所有的组合显示出来 求详细的操作步骤 谢谢!
3个回答
展开全部
公式是没有办法实现的,下面给你一段代码,你可以新建一个宏,把这些代码复制进去
m = 2
For x = 1 To 13
For y = 1 To 13
For Z = 1 To 13
For a = 1 To 13
For b = 1 To 13
If x <> y And x <> Z And x <> a And x <> b And y <> Z And y <> a And y <> b And Z <> a And Z <> b And a <> b Then
Cells(m, 1) = x: Cells(m, 2) = y: Cells(m, 3) = Z: Cells(m, 4) = a: Cells(m, 5) = b: m = m + 1
End If
Next
Next
Next
Next
Next
上面代码,先后顺序的没有排除。
m = 2
For x = 1 To 13
For y = 1 To 13
For Z = 1 To 13
For a = 1 To 13
For b = 1 To 13
If x <> y And x <> Z And x <> a And x <> b And y <> Z And y <> a And y <> b And Z <> a And Z <> b And a <> b Then
Cells(m, 1) = x: Cells(m, 2) = y: Cells(m, 3) = Z: Cells(m, 4) = a: Cells(m, 5) = b: m = m + 1
End If
Next
Next
Next
Next
Next
上面代码,先后顺序的没有排除。
2013-06-22
展开全部
Sub 组合13选5()
Dim A, B, C, D, E, N, ARR(1 To 65536, 1 To 5)
For A = 1 To 9
For B = A + 1 To 10
For C = B + 1 To 11
For D = C + 1 To 12
For E = D + 1 To 13
N = N + 1
ARR(N, 1) = A
ARR(N, 2) = B
ARR(N, 3) = C
ARR(N, 4) = D
ARR(N, 5) = E
Next
Next
Next
Next
Next
[A1:E65536] = ARR
End Sub
-------------
鼠标指向工作表标签 右键 查看代码 把上面的代码复制进去 按F5
Dim A, B, C, D, E, N, ARR(1 To 65536, 1 To 5)
For A = 1 To 9
For B = A + 1 To 10
For C = B + 1 To 11
For D = C + 1 To 12
For E = D + 1 To 13
N = N + 1
ARR(N, 1) = A
ARR(N, 2) = B
ARR(N, 3) = C
ARR(N, 4) = D
ARR(N, 5) = E
Next
Next
Next
Next
Next
[A1:E65536] = ARR
End Sub
-------------
鼠标指向工作表标签 右键 查看代码 把上面的代码复制进去 按F5
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
公式不行,VBA代码可以,要不?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询