
想在EXCEL中找出0-9中和为24的6个数,可不可以给出准确的过程
要求一定要简单而明了,在EXCEL中(1)在0-9数字中随意找6个数可重复,和为24(2)在0-9数字中随意找5个数可重复,和为24(3)在0-9数字中随意找4个数可重复...
要求一定要简单而明了,
在EXCEL中
(1)在0-9数字中随意找6个数可重复,和为24
(2)在0-9数字中随意找5个数可重复,和为24
(3)在0-9数字中随意找4个数可重复,和为24
告诉我方法,可加分 展开
在EXCEL中
(1)在0-9数字中随意找6个数可重复,和为24
(2)在0-9数字中随意找5个数可重复,和为24
(3)在0-9数字中随意找4个数可重复,和为24
告诉我方法,可加分 展开
展开全部
数字可以重复,这样的数的组合成24太多了。即使用VBA也算不完,给你VBA代码,运行不结束按CRTL+PAUSE BREAK健。A1、A2、A3...A9、A10输入1、2、3、、、9、0等10个数字。运行代码后,从B1-G1起按行显示组合,记住CRTL+PAUSE BREAK健中断结束代码。
(1)题:
Sub NUM24()
n = 1
For a = 1 To 10
For b = 1 To 10
For c = 1 To 10
For d = 1 To 10
For e = 1 To 10
For f = 1 To 10
If Cells(a, 1) + Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) + Cells(f, 1) = 24 Then
Cells(n, 2) = Cells(a, 1)
Cells(n, 3) = Cells(b, 1)
Cells(n, 4) = Cells(c, 1)
Cells(n, 5) = Cells(d, 1)
Cells(n, 6) = Cells(e, 1)
Cells(n, 7) = Cells(f, 1)
n = n + 1
End If
Next f
Next e
Next d
Next c
Next b
Next a
End Sub
(2)题:
Sub NUM24()
n = 1
For a = 1 To 10
For b = 1 To 10
For c = 1 To 10
For d = 1 To 10
For e = 1 To 10
If Cells(a, 1) + Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) = 24 Then
Cells(n, 2) = Cells(a, 1)
Cells(n, 3) = Cells(b, 1)
Cells(n, 4) = Cells(c, 1)
Cells(n, 5) = Cells(d, 1)
Cells(n, 6) = Cells(e, 1)
n = n + 1
End If
Next e
Next d
Next c
Next b
Next a
End Sub
(3)题:
Sub NUM24()
n = 1
For a = 1 To 10
For b = 1 To 10
For c = 1 To 10
For d = 1 To 10
If Cells(a, 1) + Cells(b, 1) + Cells(c, 1) + Cells(d, 1) = 24 Then
Cells(n, 2) = Cells(a, 1)
Cells(n, 3) = Cells(b, 1)
Cells(n, 4) = Cells(c, 1)
Cells(n, 5) = Cells(d, 1)
n = n + 1
End If
Next d
Next c
Next b
Next a
End Sub
(1)题:
Sub NUM24()
n = 1
For a = 1 To 10
For b = 1 To 10
For c = 1 To 10
For d = 1 To 10
For e = 1 To 10
For f = 1 To 10
If Cells(a, 1) + Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) + Cells(f, 1) = 24 Then
Cells(n, 2) = Cells(a, 1)
Cells(n, 3) = Cells(b, 1)
Cells(n, 4) = Cells(c, 1)
Cells(n, 5) = Cells(d, 1)
Cells(n, 6) = Cells(e, 1)
Cells(n, 7) = Cells(f, 1)
n = n + 1
End If
Next f
Next e
Next d
Next c
Next b
Next a
End Sub
(2)题:
Sub NUM24()
n = 1
For a = 1 To 10
For b = 1 To 10
For c = 1 To 10
For d = 1 To 10
For e = 1 To 10
If Cells(a, 1) + Cells(b, 1) + Cells(c, 1) + Cells(d, 1) + Cells(e, 1) = 24 Then
Cells(n, 2) = Cells(a, 1)
Cells(n, 3) = Cells(b, 1)
Cells(n, 4) = Cells(c, 1)
Cells(n, 5) = Cells(d, 1)
Cells(n, 6) = Cells(e, 1)
n = n + 1
End If
Next e
Next d
Next c
Next b
Next a
End Sub
(3)题:
Sub NUM24()
n = 1
For a = 1 To 10
For b = 1 To 10
For c = 1 To 10
For d = 1 To 10
If Cells(a, 1) + Cells(b, 1) + Cells(c, 1) + Cells(d, 1) = 24 Then
Cells(n, 2) = Cells(a, 1)
Cells(n, 3) = Cells(b, 1)
Cells(n, 4) = Cells(c, 1)
Cells(n, 5) = Cells(d, 1)
n = n + 1
End If
Next d
Next c
Next b
Next a
End Sub
更多追问追答
追问
可我不会用VBA,能不能给个具体步骤。最好是准确而详细的。从头开始的。
追答
第一步:新建一个EXCEL表,在A1-A10中输入数字1-9和0(最后是0)。第二步:按键ALT+F11,会弹出一个窗口,双击左边的SHEET1,粘贴上面的Sub NUM24()。。。一直到第一个END SUB(共有三段这样代码,取其中一个)第三步,按F5运行。如果老没运行完,则按CTRL+PAUSE BREAK键中止运行。由于提出问题的答案太多,要穷尽所有需运行很长时间,不知有没必要。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询