ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   xlTextFormat in TextToColumns (https://www.excelbanter.com/excel-programming/343820-xltextformat-texttocolumns.html)

CinqueTerra

xlTextFormat in TextToColumns
 
I am parsing fixed width data with the following code:

Range("a1", ActiveCell.SpecialCells(xlLastCell)).Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(8, 1), Array(11, 9), Array(12, 1))

The data in the last array is numeric. I need it to be brought in as text
so as not to loose the leading zeros. How do I apply xlTextFormat?

Thanks in advance!

Dave Peterson

xlTextFormat in TextToColumns
 
Array(12, 1)
becomes
Array(12, xlTextFormat)
or
Array(12, 2)

Sometimes, it's quicker to record a macro when you do this manually and look at
the code.


CinqueTerra wrote:

I am parsing fixed width data with the following code:

Range("a1", ActiveCell.SpecialCells(xlLastCell)).Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(8, 1), Array(11, 9), Array(12, 1))

The data in the last array is numeric. I need it to be brought in as text
so as not to loose the leading zeros. How do I apply xlTextFormat?

Thanks in advance!


--

Dave Peterson

CinqueTerra

xlTextFormat in TextToColumns
 
Awesome - Thanks!


"Dave Peterson" wrote:

Array(12, 1)
becomes
Array(12, xlTextFormat)
or
Array(12, 2)

Sometimes, it's quicker to record a macro when you do this manually and look at
the code.


CinqueTerra wrote:

I am parsing fixed width data with the following code:

Range("a1", ActiveCell.SpecialCells(xlLastCell)).Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(8, 1), Array(11, 9), Array(12, 1))

The data in the last array is numeric. I need it to be brought in as text
so as not to loose the leading zeros. How do I apply xlTextFormat?

Thanks in advance!


--

Dave Peterson



All times are GMT +1. The time now is 12:31 PM.

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