ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Can I save "Data Text to columns" definitions (https://www.excelbanter.com/excel-discussion-misc-queries/251519-can-i-save-data-text-columns-definitions.html)

Marg

Can I save "Data Text to columns" definitions
 
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. Howard Kittle

Can I save "Data Text to columns" definitions
 
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

"marg" wrote in message
...
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).





All times are GMT +1. The time now is 06:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com