【发布时间】:2018-06-17 10:01:23
【问题描述】:
我有一个现在可以使用的代码,并列出了 6 长度的数字。但它们是重复的。但这些数字是重复的。我需要唯一的非重复 6 位数字。 我现在有这种结果。1 1 1 3 4 6 但我需要不同且不重复的结果。谢谢你的帮助。
Sub AllCombinations()
Dim nums(): nums = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
Dim arValues(999999, 5)
Dim n1 As Integer, n2 As Integer, n3 As Integer, n4 As Integer, n5 As Integer, n6 As Integer, x As Long
For n1 = 0 To UBound(nums)
For n2 = 0 To UBound(nums)
For n3 = 0 To UBound(nums)
For n4 = 0 To UBound(nums)
For n5 = 0 To UBound(nums)
For n6 = 0 To UBound(nums)
arValues(x, 0) = nums(n1)
arValues(x, 1) = nums(n2)
arValues(x, 2) = nums(n3)
arValues(x, 3) = nums(n4)
arValues(x, 4) = nums(n5)
arValues(x, 5) = nums(n6)
x = x + 1
Next
Next
Next
Next
Next
Next
Range("A1").Resize(1000000, 6).Value2 = arValues
End Sub
【问题讨论】:
标签: excel vba unique combinations