+ Reply to Thread
Results 1 to 9 of 9

Export Multiple Cells Into Multiple *.txt Files

  1. #1
    Registered User
    Join Date
    08-11-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2007
    Posts
    3

    Export Multiple Cells Into Multiple *.txt Files

    I have a very similar issue as to what is described in this thread.

    http://www.excelforum.com/excel-prog...-encoding.html

    I have an excel spreadsheet about 2000 rows long and only 2 columns wide. I need each row to be exported into its own txt file. The contents of the txt file should be what's in Column B. And the name of the txt file should be what's in Column A. I tried modifying some of the code in the above thread, but honestly don't know enough about excel macro's and vba to get any positive results.

    I would appreciate some help.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export Multiple Cells Into Multiple *.txt Files

    This should do it, just edit the variables in the first two lines of code to point to the correct sheet name and the desired savepath:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-11-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Export Multiple Cells Into Multiple *.txt Files

    Thanks for the quick response and help.

    That didn't quite work for me though.

    It did create a large number of text files, all with the proper name except for the first one. The first txt file created was named the value in column B instead of column A. The other problem is that all of the files are blank. None of the Column B data wound up in the txt files.

    While waiting for a response last night I was playing around with the code in the thread I mentioned earlier. I was able to get it to work, well....mostly. It will create all the txt files named perfectly. It will dump all the data into the text files perfectly. But there seem to be hidden charachters that are preventing it from working for my application.

    For example. Text file one is named p0001s1.txt and its contents are telnet 10.9.1.65.

    If I rename this file to .bat and execute with command prompt it shows 'telnet' is not recognized as an internal or external command, operable program or batch file.


    What are these hidden charachters that are being copied over from excel? Any idea how I can get rid of them?

    Again, I have no VB experience. I understand some basic concepts and have dabbled in Objective C, but thats it. I greatly appreciate any help.

    Here is the code I'm using right now.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-11-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Export Multiple Cells Into Multiple *.txt Files

    Ascii was the answer I was looking for!

    UTF-8 format was inserting some hidden characters but ascii works just fine.

    Here is the code that I ended up with.

    Hope it helps someone else.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Export Multiple Cells Into Multiple *.txt Files

    I'd prefer

    Please Login or Register  to view this content.
    Last edited by snb; 09-07-2010 at 09:33 AM.

  6. #6
    Registered User
    Join Date
    12-19-2012
    Location
    LA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Export Multiple Cells Into Multiple *.txt Files

    thanks to all who contributed to this thread. i had a list of 20,000 patients and i needed an easy way to convert the list into individual files. awesome!!!

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export Multiple Cells Into Multiple *.txt Files

    I have marked this thread solved for you.
    In the future please select Thread Tools from the menu above and mark the thread as solved. Thanks.

  8. #8
    Registered User
    Join Date
    12-19-2012
    Location
    LA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Export Multiple Cells Into Multiple *.txt Files

    sorry JBeaucaire.. are you talking to me? or to the original poster?
    Last edited by magsmags; 01-10-2013 at 01:11 PM. Reason: added username for clarification of my question

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export Multiple Cells Into Multiple *.txt Files

    The OP. Yeah, him..... (innocent)

+ 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