展开全部
33个中取任意4个的宏如下:
Sub test()
Dim i, j, k, l As Byte
Application.ScreenUpdating = False
Cells(1, 1).Select
For i = 1 To 30
For j = i + 1 To 31
For k = j + 1 To 32
For l = k + 1 To 33
Selection = i
Selection.Offset(0, 1) = j
Selection.Offset(0, 2) = k
Selection.Offset(0, 3) = l
Selection.Offset(1, 0).Select
Next
Next
Next
Next
Application.ScreenUpdating = True
End Sub
33个中取任意3个的宏如下:
Sub test()
Dim i, j, k As Byte
Application.ScreenUpdating = False
Cells(1, 1).Select
For i = 1 To 31
For j = i + 1 To 32
For k = j + 1 To 33
Selection = i
Selection.Offset(0, 1) = j
Selection.Offset(0, 2) = k
Selection.Offset(1, 0).Select
Next
Next
Next
Application.ScreenUpdating = True
End Sub
33个中取任意2个的宏如下:
Sub test()
Dim i, j As Byte
Application.ScreenUpdating = False
Cells(1, 1).Select
For i = 1 To 32
For j = i + 1 To 33
Selection = i
Selection.Offset(0, 1) = j
Selection.Offset(1, 0).Select
Next
Next
Application.ScreenUpdating = True
End Sub
在2007版中,还可以实现取5个的,自己对照修改吧。取6个以上,格子不够。
Sub test()
Dim i, j, k, l As Byte
Application.ScreenUpdating = False
Cells(1, 1).Select
For i = 1 To 30
For j = i + 1 To 31
For k = j + 1 To 32
For l = k + 1 To 33
Selection = i
Selection.Offset(0, 1) = j
Selection.Offset(0, 2) = k
Selection.Offset(0, 3) = l
Selection.Offset(1, 0).Select
Next
Next
Next
Next
Application.ScreenUpdating = True
End Sub
33个中取任意3个的宏如下:
Sub test()
Dim i, j, k As Byte
Application.ScreenUpdating = False
Cells(1, 1).Select
For i = 1 To 31
For j = i + 1 To 32
For k = j + 1 To 33
Selection = i
Selection.Offset(0, 1) = j
Selection.Offset(0, 2) = k
Selection.Offset(1, 0).Select
Next
Next
Next
Application.ScreenUpdating = True
End Sub
33个中取任意2个的宏如下:
Sub test()
Dim i, j As Byte
Application.ScreenUpdating = False
Cells(1, 1).Select
For i = 1 To 32
For j = i + 1 To 33
Selection = i
Selection.Offset(0, 1) = j
Selection.Offset(1, 0).Select
Next
Next
Application.ScreenUpdating = True
End Sub
在2007版中,还可以实现取5个的,自己对照修改吧。取6个以上,格子不够。
展开全部
要是算有多少种可能性,比如每组都是7个数,那就是7*7*7*7
要是列出来所有的可能性,就用代码,枚举法
不过这么多写出来也看不过来吧
要是列出来所有的可能性,就用代码,枚举法
不过这么多写出来也看不过来吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2018-10-18 · 知道合伙人互联网行家
关注
展开全部
Sub Click()
Dim a, b, c, d, e, f, i
i = 1
For a = 1 To 12
For b = a + 1 To 12
For c = b + 1 To 12
For d = c + 1 To 12
For e = d + 1 To 12
For f = e + 1 To 12
Cells(i, 1) = a
Cells(i, 2) = b
Cells(i, 3) = c
Cells(i, 4) = d
Cells(i, 5) = e
Cells(i, 6) = f
i = i + 1
Next f
Next e
Next d
Next c
Next b
Next a
End Sub
Dim a, b, c, d, e, f, i
i = 1
For a = 1 To 12
For b = a + 1 To 12
For c = b + 1 To 12
For d = c + 1 To 12
For e = d + 1 To 12
For f = e + 1 To 12
Cells(i, 1) = a
Cells(i, 2) = b
Cells(i, 3) = c
Cells(i, 4) = d
Cells(i, 5) = e
Cells(i, 6) = f
i = i + 1
Next f
Next e
Next d
Next c
Next b
Next a
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
写代码需要具体文件,规则详情
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询