我有两列A& B我需要按顺序附加它们并获得结果,例如A列第一个单元格,然后是B列第一个单元格,然后是A列第二个单元格,接着是B列第二个单元格
A栏 琼斯 安卓 1234FG thepark
B栏 JONES ANDROID 1234SS PARK
结果 琼斯 JONES 安卓 ANDROID 1234FG 1234SS 公园 PARK
请建议任何公式或VBA代码以获得给定的结果。
答案 0 :(得分:0)
请参阅以下代码
Sub test()
Dim i As Long, j As Long
Dim output As String
Dim text1 As String
Dim text2 As String
Dim text1split1
Dim text1split2
Dim lastrow As Long
lastrow = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To lastrow
text1 = Range("A" & i).Value
text2 = Range("B" & i).Value
text1split1 = Split(text1, " ")
text1split2 = Split(text2, " ")
For j = 0 To UBound(text1split1)
If output <> "" Then
output = output & " " & text1split1(j) & " " & text1split2(j)
Else
output = text1split1(j) & " " & text1split2(j)
End If
Next j
Range("C" & i).Value = output
Next i
End Sub