+ Reply to Thread
Results 1 to 5 of 5

Conversion of pipe delimitation text file into excel using vbscript

  1. #1
    Registered User
    Join Date
    10-18-2018
    Location
    melbourne
    MS-Off Ver
    MS Office 2007
    Posts
    3

    Conversion of pipe delimitation text file into excel using vbscript

    My requirement is to convert below text (sample.txt) file into an excel file (.XLSX) .All data should appear in different
    column in excel.First two lines (in upper and lower case) need to be treadted as header in the excel file.

    Would appreciate if some one could please help me in vbscript.

    sample.txt
    Name|Age|***|Department
    name|age|***|department

    Abc|23|Male|Computer
    XYZ|24|Male|Arts

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Conversion of pipe delimitation text file into excel using vbscript

    hmmm use text to column with | delimiter?

    assume column A is where the text is
    Please Login or Register  to view this content.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    10-18-2018
    Location
    melbourne
    MS-Off Ver
    MS Office 2007
    Posts
    3

    Re: Conversion of pipe delimitation text file into excel using vbscript

    Thanks a lot for your response. I am quite new in vbscripting and still unable to write a complete code .

    It would be great help if you could please provide me complete code. I need to just convert "pipe delimited" file into an excel .

    Here is example of my text input file :-

    Name|age|gender|department|year
    praveen|23|male|computer|2010
    ptalakes|23|female|arts |2018

    Output should be in excel file as below in corresponding cell :-

    Name age gender department year
    praveen 23 male computer 2010
    ptalakes 23 female arts 2018

    Thanks in advance
    Praveen

  4. #4
    Registered User
    Join Date
    10-18-2018
    Location
    melbourne
    MS-Off Ver
    MS Office 2007
    Posts
    3

    Re: Conversion of pipe delimitation text file into excel using vbscript

    What i have done so far is :- first converted .txt file into csv ...and then attempting to convert csv into xls . Looks like my approach is not correct and seems quite lengthy . Need your help pleae with complete code....

    Dim fso, ts1, ts2

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts1 = fso.OpenTextFile("C:\Users\user\Desktop\1910.txt")
    Set ts2 = fso.CreateTextFile("C:\Users\user\Desktop\1910.csv")
    Do Until ts1.AtEndOfStream
    ts2.WriteLine Replace(ts1.ReadLine, "|", ",")
    Loop

    ts2.Close
    ts1.Close

  5. #5
    Registered User
    Join Date
    09-16-2017
    Location
    Agra
    MS-Off Ver
    2013
    Posts
    72

    Re: Conversion of pipe delimitation text file into excel using vbscript

    Dear Praveen, I suggest you record a macro with using relative references.
    Steps are as follows( key Steps)
    1. Open a macroenabled workbook.
    2. Start recording
    3. goto data tab and import the txt file you want to import.
    4. Use Text to col. whizard to convert
    5. SAve and exit macro.

    Try this and you will have your working code ready. We can review the code to eliminate those extra steps which excel normally records.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Combine Excel Sheets (+2 Million Rows total) and Create Pipe Delimited TEXT File
    By kestefon in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-05-2013, 08:51 PM
  2. Replies: 4
    Last Post: 05-02-2013, 11:16 AM
  3. VBA macro for Inserting text file(having pipe as delimiter) into Excel sheet
    By Nusrat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-26-2013, 05:40 AM
  4. Convert Pipe Delimited Text File into CSV File
    By sachin29feb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-28-2012, 10:47 AM
  5. need macro to create pipe delimited text file from excel
    By nefkho in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-04-2012, 12:03 PM
  6. Save CSV file as Pipe delimited text file
    By germantim in forum Excel General
    Replies: 5
    Last Post: 08-11-2009, 12:21 PM

Tags for this Thread

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