Separate text in a single cell into multiple columns - Writing a macro


New Member
Mar 21, 2010
Hi All,

I have a *.lis extension file opened in excel. The text is in a single cell and I wish to separate the information into separate columns. Part of the text is delimited by "|" but some isn't.

It is a GL output which someone runs everyday, I wish to write a macro to separate the info into different columns and allow me to use pivot table to manipulate it. Text to columns doesn't work since the width varies from line to line.

| True Account | Opening Balance | Net Movement | Closing Balance | <-- Heading
| Inter Ledger Clearing Accounts... (12234 | 11.00 | 5.00 | 16.00 | <--- Line 1
| Clearing Account...... (12277 | 33.00 | 1.00 | 34.00 | <--- Line 2
| IRS Account Interest Income...... (14477 | 1,000.00 | 1.00 | 1,001.00 | <--- Line 3

I wish to separate it into 5 different columns

*Line 1 Target Example*
1) True Account [Inter Ledger Clearing Accounts] 2) True Account Number* [12234] 3) Opening Balance [11.00] 4) Net Movement [5.00] 5) Closing Balance [16.00]

*New column I wish to write a macro to add this column in.

Can someone please assist me in this? Hope I'm clear on what's required. If not please let me know. Thanks a mill!


Well-known Member
Nov 9, 2009
Sub tst()
  Sheets(1).Columns(1).TextToColumns , 1, -4142, , False, False, False, False, True, "|"
  Sheets(1).Columns(1).TextToColumns , 1, -4142, , False, False, False, False, True, "("
End Sub

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...