+ Reply to Thread
Results 1 to 2 of 2

Hepl for convert txt file to excel using vba sub

  1. #1
    Registered User
    Join Date
    01-25-2013
    Location
    Viet Nam
    MS-Off Ver
    Excel 2007
    Posts
    7

    Hepl for convert txt file to excel using vba sub

    Halo everyone,
    I have problem when open the txt file.
    This is some steps I use to open txt file:

    open excel application
    step 1: File --> Open --> open txt file

    step 2: in "Text inport wizard" step 1 of 3 window
    - Choose the file type that best describes your data: choose "Delimited"
    - srat import at row: 1
    - File origin: 65001: Unicode (UTF-8)

    step 2: in "Text inport wizard" step 2 of 3 window
    - Delimiters: tab
    - Text gualifier: {none}

    step 3: in "Text inport wizard" step 3 of 3 window
    - Choose all data record in "Data preview"
    - Column data format: text
    - Finish

    step 4 ---> file --> save as --> convert to xls type.

    I want to convert steps above to vba code. When run vba code, my txt file will automatically convert to txt file.

    So this is something i want:

    Input: the path contains 1 or more txt file.

    Output: the excel file with same name with txt file and Delimiters, Text gualifier, Column data format...... same steps above.

    Please check attachments file. That is a sample, it has only 4 columns, actually, my txt file has 100 or more columns.

    Thanks all and best regards.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Hepl for convert txt file to excel using vba sub

    Sub openTextTabDelimited()
    Workbooks.OpenText Filename:="C:\Users\UserName\Desktop\sample.txt", _
    DataType:=xlDelimited, Tab:=True
    End Sub
    If solved remember to mark Thread as solved

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1