Can I save "Data Text to columns" definitions

M

marg

I have to convert text to columns and have to repeat the process every time
the data changes. The file definitions are constant and wondered if there was
any way that I could save the definitions and merely re-run the text to
column function based on new data using an existing definition.

EG
01000123000164

Use Data Text to columns to get
01 000123 000164 columns of data

The column break is constant ie column 1 = positions 1&2, column 2 =
positions 3-8 and column 3 = positions 9 -14. This I would like to save so I
could just re-apply this definition to new data. At the moment I have to keep
re-iterating the column break points for each new data set (often a record
set is quite big >100 characters).
 
L

L. Howard Kittle

Select your data and try using the macro recorder on an example of your
data. It will look something like this.

Sub Macro1()
Selection.TextToColumns Destination:=Range("A8"), _
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(2, 1), Array(8, 1)), _
TrailingMinusNumbers:=True
End Sub

Now select your data and run the macro.

HTH
Regards,
Howard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top