I have two columns A & B i need to append them in a sequential order and obtains the result such as Column A first cell followed by column B first cell followed by Column A second cell followed by column B second cell
Column A Jones android 1234FG thepark
Column B JONES ANDROID 1234SS PARK
Result Jones JONES android ANDROID 1234FG 1234SS thepark PARK
Kindly advise any formulas or VBA code to obtain the given result.
please see the below code
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.