在excel中是否有办法找出表的所有可能组合,但每列可以采用2或3个值。 ?
让我们说这是我需要排序的:
A A | B | C | D |
1 1 | 1 | 1 | 1 |
2 1 | 1 | 1 | 2 |
3 1 | 1 | 2 | 1 |
1 | 2 | 1 | 1 |
2 | 1 | 1 | 1 |
..............
...............
B
1
2
C
1
2
D
1
2
3
答案 0 :(得分:0)
可能是你在这之后(没有经过测试,但至少应该给你这个想法)
Sub Combinations
Dim i As Long, j As Long, k As Long, l As Long
Dim iRow As Long
For i = 1 To 3 ‘ change 3 to your first column actual last number
For j = 1 To 2‘ change 2 to your second column avtual last number
For k = 1 To 3 ‘ change 3 to your third column actual last number
For l = 1 To 4 ‘ change 4 to your fourth column actual last number
iRow = iRow + 1
Cells(iRow,1).Resize(,4).Value = Array(i,j,k,l)
Next
Next
Next
Next
End Sub