How can I generate all possible combinations, in Excel, by using only 3, 6 and 9 in a 5 digit number? Naturally digits can repeat.
如何在Excel中生成所有可能的组合,只使用5位数的3,6和9?当然,数字可以重复。
I am trying to learn more about EXCEL and this is something I cannot figure out - how to generate all possible combinations and see them instead of just having a number of possibilities.
我想了解更多关于EXCEL的内容,这是我无法弄清楚的 - 如何生成所有可能的组合并看到它们而不是仅仅具有多种可能性。
I've looked through many forums, there's nothing I can use...
我浏览了很多论坛,没有什么可以用的......
http://planetcalc.com/3756/?license=1 - This link is to an online generator, however there must be a mistake in its code since it doesn't show 5 digit numbers.
http://planetcalc.com/3756/?license=1 - 此链接指向在线生成器,但其代码中必定存在错误,因为它不显示5位数字。
1 个解决方案
#1
Just loop over the selections:
只需循环选择:
Sub Maja()
Dim K As Long
K = 1
vals = Array("3", "6", "9")
For Each a In vals
For Each b In vals
For Each c In vals
For Each d In vals
For Each e In vals
Cells(K, 1) = a & b & c & d & e
K = K + 1
Next e
Next d
Next c
Next b
Next a
MsgBox K
End Sub
A snap of the top of the list:
列表顶部的快照:
NOTE:
Technically, you would call these permutations rather than combinations because values like 33363 and 33336 both appear in the list as they represent different numerical values.
从技术上讲,你会调用这些排列而不是组合,因为像33363和33336这样的值都出现在列表中,因为它们代表不同的数值。
#1
Just loop over the selections:
只需循环选择:
Sub Maja()
Dim K As Long
K = 1
vals = Array("3", "6", "9")
For Each a In vals
For Each b In vals
For Each c In vals
For Each d In vals
For Each e In vals
Cells(K, 1) = a & b & c & d & e
K = K + 1
Next e
Next d
Next c
Next b
Next a
MsgBox K
End Sub
A snap of the top of the list:
列表顶部的快照:
NOTE:
Technically, you would call these permutations rather than combinations because values like 33363 and 33336 both appear in the list as they represent different numerical values.
从技术上讲,你会调用这些排列而不是组合,因为像33363和33336这样的值都出现在列表中,因为它们代表不同的数值。