问题:有多个2列组成的多列数据,要整合成一个2列的数据,如图
步骤:
1.先把原始列中所有的空值用文字代替,此为方便VB代码的运行:按Ctrl+G--定位条件--空值--确定--输入文字,按Ctrl+Enter,会自动填充全部空值
2.运行VBA代码:
Sub Combine()
Dim OrigA
Dim OrigB
Dim strA As String
Dim strB As String
Dim strDelim As String
Dim lngCol As Long
strDelim = "||"
strA = Join(Application.Transpose(Range([a1], Cells(Rows.Count, "A").End(xlUp))), strDelim)
strB = Join(Application.Transpose(Range([b1], Cells(Rows.Count, "b").End(xlUp))), strDelim)
For lngCol = Columns("C").Column To Columns("ALC").Column - 2 Step 2
If Application.CountA(Columns