我需要以下 excel 以及看起来像 VBA 问题的帮助。
这里的想法是在每个分组中生成所有可能的组合(不重复)。
输入
COLUMN A | COLUMN B
A | 1
X | 1
D | 1
C | 2
E | 2
输出
COLUMN A | COLUMN B
A | X
A | D
X | D
X | A
D | A
D | X
C | E
E | C
我设法做到了....仅当数据在同一组中时,我如何让它运行。
Option Explicit
Sub Sample()
Dim i As Long, j As Long
Dim CountComb As Long, lastrow As Long
Application.ScreenUpdating = False
CountComb = 0: lastrow = 1
For i = 1 To 10: For j = 1 To 10
Range("G" & lastrow).Value = Range("A" & i).Value & "/" & _
Range("B" & j).Value
lastrow = lastrow + 1
CountComb = CountComb + 1
Next: Next
Application.ScreenUpdating = True
End Sub