Convert one column of long data into multiple columns based on a specific string of text

myawan

New Member
Joined
Mar 2, 2019
Messages
7
Hi experts,

I have a long list of data exported into excel from a text file. This file contains output of a command from multiple network elements.
Whenever there is a text string 'Welcome to', the below mentioned text should be copied to a new column till the next 'Welcome to' appears. In this case I will have separate column for each network element.


--------------------------------------------------
MINI-LINK Traffic Node Command Line Interface
--------------------------------------------------
Welcome to DF0002
Password: ********
DF0002>s h o w v l a n
vlan1
vlan2
vlan3
--------------------------------------------------
MINI-LINK Traffic Node Command Line Interface
--------------------------------------------------
Welcome to DF0003
Password: ********
DF0003>s h o w v l a n
vlan4
vlan5

<tbody>
</tbody>

The output should be like this

Welcome to DF0002
Welcome to DF0003
Password: ********Password: ********
DF0002>s h o w v l a n DF0003>s h o w v l a n
vlan1vlan4
vlan2vlan5
vlan3
--------------------------------------------------
MINI-LINK Traffic Node Command Line Interface
--------------------------------------------------

<tbody>
</tbody>
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
How about
Code:
Sub myawan()
   Dim Ar As Areas
   Dim i As Long
   With Range("A1", Range("A" & Rows.Count).End(xlUp))
      .Replace "Welcome", "=xxxWelcome", xlPart, , False, , False, False
      Set Ar = .SpecialCells(xlFormulas, xlErrors).Areas
      .Replace "=xxxWelcome", "Welcome", xlPart, , False, , False, False
   End With
   For i = 1 To Ar.Count - 1
      Range(Ar(i), Ar(i + 1).Offset(-1)).Copy Cells(1, i + 1)
   Next i
      Range(Ar(i), Ar(i).End(xlDown)).Copy Cells(1, i + 1)
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,731
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top