+ Reply to Thread
Results 1 to 5 of 5

Batch convert .txt files to .xls

  1. #1
    Registered User
    Join Date
    12-17-2019
    Location
    Leeds, UK
    MS-Off Ver
    365
    Posts
    61

    Question Batch convert .txt files to .xls

    Hi all,

    I have 48 text files that need converting to Excel.
    The obvious answer found in most forums uses the following code:

    Please Login or Register  to view this content.
    The problem is this converts the text from the files in a single column of each excel workbook as opposed to distributed into columns.
    Excel's Text Wizard sorts this problem for manual conversions, so using the macro recorder, I've identified a code for manual, correct conversion as :

    Please Login or Register  to view this content.
    Can someone please suggest a code which combines the two and allows me to convert all 48 .txt files into correctly formatted Excel files, please?

    Thanks!!
    Attached Files Attached Files

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Batch convert .txt files to .xls

    Untested here :

    Please Login or Register  to view this content.

    https://stackoverflow.com/questions/...umns-using-vba

  3. #3
    Registered User
    Join Date
    12-17-2019
    Location
    Leeds, UK
    MS-Off Ver
    365
    Posts
    61

    Re: Batch convert .txt files to .xls

    Thanks, but this still has the same problem. The excel files import all the .txt data into the 1st column of the excel files..
    Attached is an example of the .txt files I'm working with
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Exclamation Re: Batch convert .txt files to .xls


    Hi,

    'cause the file does very not match the data type expected by the VBA procedure !

    So just activate the Macro Recorder and import manually the file in order to get a code base
    or just reading the VBA help according to your actual VBA procedure ...

    Edit : as it seems you already have a working procedure in your initial post so just combine it with post #2.
    Last edited by Marc L; 10-20-2022 at 12:31 PM.

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Batch convert .txt files to .xls

    Here is a similar macro to yours that will distribute the data to different columns.
    I agree with Marc L, you already have a macro to do what you are seeking ... why not use it ?

    Please Login or Register  to view this content.

+ 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. [SOLVED] Batch convert .docx to .txt
    By Cunner in forum Word Programming / VBA / Macros
    Replies: 8
    Last Post: 10-21-2021, 05:26 AM
  2. Named Parameter error (Trying to batch save as xlsx files as xml data files)
    By dzheng.328 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2019, 03:22 PM
  3. [SOLVED] Batch convert all excel files in a folder (and its subfolders) to pdf
    By billj in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-23-2019, 05:12 PM
  4. [SOLVED] Batch Convert XLSX to XLS
    By Ernching in forum Excel General
    Replies: 3
    Last Post: 08-22-2015, 11:46 AM
  5. [SOLVED] Batch convert data in multiple files (Meters to Feet)
    By chris45 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-11-2013, 12:16 PM
  6. Replies: 1
    Last Post: 11-12-2013, 03:44 PM
  7. Batch conversion of XP files to 97 files
    By AG in forum Excel General
    Replies: 2
    Last Post: 10-02-2005, 10:05 AM

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