+ Reply to Thread
Results 1 to 5 of 5

writing excel file to separate tab separated text files with header in each

  1. #1
    Registered User
    Join Date
    09-14-2014
    Location
    3819
    MS-Off Ver
    Windows 2013
    Posts
    2

    writing excel file to separate tab separated text files with header in each

    Hello,
    I am relatively new to VBA, so apologies if this is naive but I have been struggling with this. I have tried to look through past posts on this subject but have had a hard time resolving having headers and tab file output in the same solution (individually yes, but the code in each answer seemed very different and didn't know how to combine them. I am using Office 2013.

    I have an excel file with 12 columns and 123 rows. The first row is a header row that I would like repeated in every file, along with one row of data in each file (so 122 files total). I need the files to be named what is in column A for each row, but that column not be included in the file (so column 2-12 will be written to file). Finally, I need the output saved as a Tab separated txt file.

    Thank you very much in advance for your help...having a hard time figuring this one out on my own.

    EcoHIV_metadata.xlsm

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: writing excel file to separate tab separated text files with header in each

    Hi see if this helps. Run the code named CreateFiles. Note that if there is a file with the same under the same folder it will be deleted and replaced with a new one.

    Please Login or Register  to view this content.
    Hope it helps

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

    Lightbulb Try this demonstration !


    Hi,

    needs less than 20 code lines with standard VBA functions !

    Code to paste directly in the worksheet module :

    Please Login or Register  to view this content.
    Enjoy it and don't forget to clik on bottom left star "Add Reputation", thanks !

  4. #4
    Registered User
    Join Date
    09-14-2014
    Location
    3819
    MS-Off Ver
    Windows 2013
    Posts
    2

    Re: writing excel file to separate tab separated text files with header in each

    Thank you both so much. I ended up using Marc's reply and it worked perfectly!

  5. #5
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: writing excel file to separate tab separated text files with header in each

    I am glad I was able to help. My code is longer indeed but easier to understand and debug. Just saying yeah its more than 20 lines!

    Thanks

+ 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. Replies: 7
    Last Post: 12-02-2013, 03:16 AM
  2. Search cell for multiple text , return comma separated text in separate cell if found
    By dangerdoug in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2013, 01:52 PM
  3. Writing data into excel from a text file
    By chris10 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-24-2011, 07:04 AM
  4. [SOLVED] Writing Excel data to 2 separate text files
    By new2vb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-06-2011, 12:51 PM
  5. Replies: 0
    Last Post: 05-04-2006, 06:35 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