+ Reply to Thread
Results 1 to 6 of 6

Writing Excel data to 2 separate text files

  1. #1
    new2vb
    Guest

    Wink Writing Excel data to 2 separate text files

    Hello VBexperts, VBenthus and VBnewbies,

    I am newbie to the world of VB and also to this forum.
    I need some suggestions or any kind of sample code to read the excel data and write specific columns to my text file. I need to generate 2 text files.

    Example of my problem:

    My excel file looks like this:

    Headers- A B C D
    Data - 1 2 3 4
    7 8 0 5


    One of my text file should contain:

    A D
    1 4
    7 5

    The other text file should contain:

    C
    3
    0


    Any helps will be greatly appreciated.

    Thanks,
    new2vb
    Last edited by new2vb; 06-06-2011 at 12:11 PM. Reason: Solved

  2. #2
    macromaniac
    Guest

    Re: Writing Excel data to 2 separate text files

    Hi new2vb

    I have a sample of that helps to generate text file. I am also a new member but here you need to be really fortunate for posts to be replied. My posts were ignored. I am too disappointed I hope the same doesn't turn out true in your case. Good luck.

    Please Login or Register  to view this content.
    HTH.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Writing Excel data to 2 separate text files

    Hello new2vb,

    Welcome to the Forum!

    This macro will create two text files from the specified columns. You will need to change the file path, file names, worksheet name and starting range to match what you will be using.
    Please Login or Register  to view this content.

    Adding the Macro
    1. Copy the macro above pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Make any custom changes to the macro if needed at this time.
    8. Save the Macro by pressing the keys CTRL+S
    9. Press the keys ALT+Q to exit the Editor, and return to Excel.

    To Run the Macro...
    To run the macro from Excel, open the workbook, and press ALT+F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Smile Re: Writing Excel data to 2 separate text files

    Hello,

    Please consider my solution, maybe it will be more easy, in attachement You will find working example.

    Please Login or Register  to view this content.
    Best Regards
    Maciej
    Attached Files Attached Files

  5. #5
    new2vb
    Guest

    Re: Writing Excel data to 2 separate text files

    Hey all,

    Thanks a lot for the help. Thanks macromaniac, Leith And Maczaq .
    Well Maczaq you did made my task very simple!!
    Thanks a ton for all the posts! :-)

  6. #6
    new2vb
    Guest

    Wink Re: Writing Excel data to 2 separate text files

    Dear macromaniac
    Patience is the key word for all your problems. People out here help us with no expectations in return. My problem was solved immidiately.
    I am sure they will help you out too!

    Good luck

    new2vb

    Quote Originally Posted by macromaniac View Post
    Hi new2vb

    I have a sample of that helps to generate text file. I am also a new member but here you need to be really fortunate for posts to be replied. My posts were ignored. I am too disappointed I hope the same doesn't turn out true in your case. Good luck.

    Please Login or Register  to view this content.
    HTH.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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