98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Text to column
Text to column
Resolved · Medium Priority · Version 2003
Ferdous has attended:
Excel VBA Intro Intermediate course
Text to column
What is the correct syntaxt for applying text to column on Visual Basic?
RE: Text to column
Hi Ferdous
Thanks for the question.
The easiest way to confirm this syntax is to record it but its not the most clear code.
A simple example of dividing text into 3 columns with commas seperating each item looked like:
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, _
Tab:=False, Semicolon:=False, Comma:=True, Space:=False, Other:=False, _
FieldInfo :=Array(Array(1, 1), Array(2, 2), Array(3, 1)), _
TrailingMinusNumbers:=True
The most confusing part of it is the FieldInfo. It requires an array to be built with pairs of values for each column. The first value is the column number the second the data type.
Data Types are
1 = xlTextFormat. Text
2 = xlMDYFormat. MDY Date
3 = xlDMYFormat. DMY Date
4 = xlYMDFormat. YMD Date
5 = xlMYDFormat. MYD Date
7 = xlDYMFormat. DYM Date
8 = xlYDMFormat. YDM Date
9 = xlSkipColumn. Skip Column
I hope that helps. Let me know how you get on.
Laura GB
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Sorting data stored in rowsPrimarily Excel is set up to sort data that is stored in columns rather than rows. |