Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

text column

ResolvedVersion 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 courses

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Create your own custom list on Excel 2010!

If you know how to use the auto-fill option on Excel then why not create your own customs lists?

The auto fill feature saves you time by allowing you to enter one of the list entries into a cell and then use your mouse to automatically drag the rest of the list into the cells below, above or to either side of the initial cell. When using your mouse to perform this task you will see a thin black cross appear at the bottom right hand side of the cell. Click, hold and drag to make the list appear.

Default lists include weekdays and months. To create your own list in Excel 2010 do the following;

>File
>Options
>Advanced
>Scroll right to the bottom of the page and you will see a buttom "edit custom lists", click this button
>enter your list in the list entries
>click add

Now try it out. Good luck.
>

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.08 secs.