7个数字里面选出4个数进行组合(一共35种),用EXCEL罗列出来,怎么做?
答案:1 悬赏:50 手机版
解决时间 2021-04-07 12:45
- 提问者网友:饥饿走向夜
- 2021-04-07 06:43
7个数字里面选出4个数进行组合(一共35种),用EXCEL罗列出来,怎么做?
最佳答案
- 五星知识达人网友:妄饮晩冬酒
- 2021-04-07 08:01
排列 35 种(组合:将 > 换成 <> 即可):
Sub Combine()
sd = Array(1, 2, 3, 4, 5, 6, 7)
CurrentRow = 1
For a1 = 0 To 6
For a2 = 0 To 6
If a2 > a1 Then
For a3 = 0 To 6
If a3 > a2 And a3 > a1 Then
For a4 = 0 To 6
If a4 > a3 And a4 > a2 And a4 > a1 Then
Cells(CurrentRow, 1) = sd(a1) & sd(a2) & sd(a3) & sd(a4)
CurrentRow = CurrentRow + 1
End If
Next
End If
Next
End If
Next
Next
End Sub追问第一步是什么?追答打开Excel,按 ALT+F11,选 ThisWorkbook,右键选 插入-模块,将上面代码拷入窗口右边;
回到Excel,按 ALT+F8,选 Combine,执行,OK!
Sub Combine()
sd = Array(1, 2, 3, 4, 5, 6, 7)
CurrentRow = 1
For a1 = 0 To 6
For a2 = 0 To 6
If a2 > a1 Then
For a3 = 0 To 6
If a3 > a2 And a3 > a1 Then
For a4 = 0 To 6
If a4 > a3 And a4 > a2 And a4 > a1 Then
Cells(CurrentRow, 1) = sd(a1) & sd(a2) & sd(a3) & sd(a4)
CurrentRow = CurrentRow + 1
End If
Next
End If
Next
End If
Next
Next
End Sub追问第一步是什么?追答打开Excel,按 ALT+F11,选 ThisWorkbook,右键选 插入-模块,将上面代码拷入窗口右边;
回到Excel,按 ALT+F8,选 Combine,执行,OK!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯