Text to Columns with VBA

Pesman

New Member
Joined
Jul 8, 2002
Messages
9
I've figured out how to find and import a text file into a sheet using VBA.

I've been fighting for a couple of days now on how to convert the text into columns.
I've tried recording a macro and that works fine, however, the problem is that the number of rows is not constant.

Does anyone have a quick and dirty way of doing this?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
On 2002-09-24 05:28, Pesman wrote:
I've figured out how to find and import a text file into a sheet using VBA.

I've been fighting for a couple of days now on how to convert the text into columns.
I've tried recording a macro and that works fine, however, the problem is that the number of rows is not constant.

Does anyone have a quick and dirty way of doing this?

Something like this should work:

Range("A1:A" & Range("A65536").End(xlUp).Row).TextToColumns DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 2), Array(7, 2))

Just change the field info to your requirements.

Regards,
 
Upvote 0
On 2002-09-24 05:28, Pesman wrote:
I've figured out how to find and import a text file into a sheet using VBA.

I've been fighting for a couple of days now on how to convert the text into columns.
I've tried recording a macro and that works fine, however, the problem is that the number of rows is not constant.

Does anyone have a quick and dirty way of doing this?

oops, **** SLOW board!! :smile:
_________________

Barrie Davidson
My Excel Web Page
This message was edited by Barrie Davidson on 2002-09-24 06:25
 
Upvote 0

Forum statistics

Threads
1,222,310
Messages
6,165,261
Members
451,949
Latest member
bovacik

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