Question
How do I split multiple lines of text into seperate columns within Excel?
Answer
There are a couple different methods for splitting the text, 2 of the most common are listed below.
Using Data | Text to Columns
- Open Your Excel Document
- Highlight the column you want to split the text on.
- Click on the Data tab, then Text to Columns.
- Choose a delimited format, choose Other as the delimiter then press CTRL and J on the keyboard at the same time. This makes your delimited a line break (similar to ALT + ENTER) in excel so that each line break that is found is used as the delimiter in your data.
- Follow the rest of the steps through to verify your data before completing the Text to Columns split.
Using a Macro
Sometimes using Data | Text to Columns does not function properly depending on the type of data, how the line breaks were created, etc.
- Open Your Excel Document.
- Create 4-5 blank columns to the right of the column you want to split out into multiple columns. These are needed because the data from your multiple line cell will be inserted into these fields. If you do not insert these fields the data in the fields to the right of your primary cell will be overwritten.
- Click on View | Macros | View Macros
- Type SplitText into Macro Name field.
Sub splitText() 'splits Text active cell using ALT+10 char as separator Dim splitVals As Variant Dim totalVals As Long Dim i As Integer For i = 1 To 1000 splitVals = Split(ActiveCell.Value, Chr(10)) totalVals = UBound(splitVals) Range(Cells(ActiveCell.Row, ActiveCell.Column + 1), Cells(ActiveCell.Row, ActiveCell.Column + 1 + totalVals)).Value = splitVals ActiveCell.Offset(1, 0).Activate Next i End Sub
- Click the Create button
- Highlight all the text in the VBA editor and delete it. Be careful not to delete other macros you've created.
- Close the VBA editor once you have pasted the code.
- To run the macro highlight the first cell that you want to split the data on and Click View | Macros | View Macro then click on SplitText in your macro list and click Run. This macro does the first 1000 lines, just repeat the process on the 1001 record by highlighting it and running the macro again.
Version Information
- Entered : 06/2012
You could leave a comment if you were logged in.