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

sagita

New Member
Joined
Mar 21, 2010
Messages
1
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.

*Example*
| 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!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Code:
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
 
Upvote 0

Forum statistics

Threads
1,214,813
Messages
6,121,705
Members
449,048
Latest member
81jamesacct

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