1个回答
展开全部
给你个vba的方法,假设1到15在a1到a15内,
按alt+f11,弹出的对话框左侧,双击sheet1,弹出的代码窗考入下面代码:
Sub 五个数字的排列组合()
Dim a(), i As Integer, j As Integer, r As Integer, l As Integer, m As Integer, n As Integer
a() = [A1:A7].Value
For i = 1 To 3
For j = i + 1 To 4
For l = j + 1 To 5
For m = l + 1 To 6
For n = m + 1 To 7
r = r + 1
Cells(r, 2) = a(i, 1) & a(j, 1) & a(l, 1) & a(m, 1) & a(n, 1)
Next n
Next m
Next l
Next j
Next i
End Sub
输入完成以后点击绿色三角运行。
这个公式会在b列显示出所有可能的5个数的组合。改动Cells(r, 2)中的2可以改变输出显示的区域,2代表b列。3代表c列等等。
按alt+f11,弹出的对话框左侧,双击sheet1,弹出的代码窗考入下面代码:
Sub 五个数字的排列组合()
Dim a(), i As Integer, j As Integer, r As Integer, l As Integer, m As Integer, n As Integer
a() = [A1:A7].Value
For i = 1 To 3
For j = i + 1 To 4
For l = j + 1 To 5
For m = l + 1 To 6
For n = m + 1 To 7
r = r + 1
Cells(r, 2) = a(i, 1) & a(j, 1) & a(l, 1) & a(m, 1) & a(n, 1)
Next n
Next m
Next l
Next j
Next i
End Sub
输入完成以后点击绿色三角运行。
这个公式会在b列显示出所有可能的5个数的组合。改动Cells(r, 2)中的2可以改变输出显示的区域,2代表b列。3代表c列等等。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询