我在excel表中有如下数据
A,B,C
D,E,F
我想将其转换为
A,B
A,C
B,C
D,E
D,F
E,F
我有以下宏,只能这样:
A,B
A,C
D,E
D,F
如何调整以下代码以达到目的?
Dim targetRowNumber As Long
targetRowNumber = Selection.Rows(Selection.Rows.Count).Row + 2
Dim col1 As Variant
Dim cell As Range
Dim sourceRow As Range: For Each sourceRow In Selection.Rows
col1 = sourceRow.Cells(1).Value
For Each cell In sourceRow.Cells
If Not cell.Column = Selection.Column Then
Selection.Worksheet.Cells(targetRowNumber, 1) = col1
Selection.Worksheet.Cells(targetRowNumber, 2) = cell.Value
targetRowNumber = targetRowNumber + 1
End If
Next cell
Next sourceRow