+ Reply to Thread
Results 1 to 11 of 11

Export to mulitple TXT files

  1. #1
    Registered User
    Join Date
    05-27-2019
    Location
    Bismarck, ND
    MS-Off Ver
    2013
    Posts
    7

    Export to mulitple TXT files

    Looking for some help. I'm a novice Excel user. So VBA is out of my realm. I have an Excel 2013 file with weather data. Basically columns A through M with data. I have one row for each day of the year, plus an extra row for leap year.

    Column A is the 2 digit number for month
    Column B is the 2 digit day number
    Column G is a rain data.

    I'd like to make a macro that will go through each row and create a TXT file for each day of the year. So each row creates one text file.
    The file name would be a concatenation of ColumnsA+B followed by .txt.
    So the row with June 27th data would take Column A of 05, plus column B of 27, and create a file 0527.txt

    The data within the TXT file would be filled with the same row, column G data. Hopefully I made sense. So hopefully the macro would then create 366 files in a specified folder.

    I have a few more macro's to build once I get this one working. But they are all variations of the above. So I can probably figure it out from there.

    Thanks in advance.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Export to mulitple TXT files

    Try this.

    Please Login or Register  to view this content.
    Martin

  3. #3
    Registered User
    Join Date
    05-27-2019
    Location
    Bismarck, ND
    MS-Off Ver
    2013
    Posts
    7

    Re: Export to mulitple TXT files

    That pretty much did it. But something odd starts happening starting with my 0705.txt file. It starts showing values out past 2 decimal places. I double checked the data I entered. None of the data has more than 2 decimals. I even formatted that column to be a number and 2 decimal places. But the files still have some extra digits. Not all. Just some

    The only other thing I'll need to do is have another macro that picks column H, and the file name will be 0527rh.txt instead. What would that one look like?

    Thanks again.

  4. #4
    Registered User
    Join Date
    05-27-2019
    Location
    Bismarck, ND
    MS-Off Ver
    2013
    Posts
    7

    Re: Export to mulitple TXT files

    Probably just as easy to attach my Excel file. Basically need 6 sets of files, made by 6 macros. Data from columns C, G, H, I, J, and K. Just with slightly different file names.

    Hopefully I attached this right.

    Thanks
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Export to mulitple TXT files

    Try
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-27-2019
    Location
    Bismarck, ND
    MS-Off Ver
    2013
    Posts
    7

    Re: Export to mulitple TXT files

    That worked perfectly. Thanks Jindon.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Export to mulitple TXT files

    You are welcome.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  8. #8
    Registered User
    Join Date
    05-27-2019
    Location
    Bismarck, ND
    MS-Off Ver
    2013
    Posts
    7

    Re: Export to mulitple TXT files

    Sorry to dig up an old thread, but I went to update the data in my Excel file. Did a save as Excel-macro enabled file as it wasn't before. But now I'm getting a "Run-time error '52': Bad file name or number error.

    When I go to debug, "Open myDir & .Cells(i, "a").Text & .Cells(i, "b").Text & ".txt" For Output As #ff" is highlighted.

    Any help is appreciated.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    05-27-2019
    Location
    Bismarck, ND
    MS-Off Ver
    2013
    Posts
    7

    Re: Export to mulitple TXT files

    I should add, I'm using Office 365 on my PC now.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Export to mulitple TXT files

    When you change the path...
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    05-27-2019
    Location
    Bismarck, ND
    MS-Off Ver
    2013
    Posts
    7

    Re: Export to mulitple TXT files

    Thank you for that. Now I need to go through my data and see what needs updating.

+ 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. Excel VBA export mulitple rows to PDF
    By jannerman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2015, 09:38 AM
  2. Help with VBA to process 10k + files each with mulitple sheets
    By darin.m in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-23-2014, 09:03 PM
  3. Replies: 1
    Last Post: 03-22-2013, 10:05 AM
  4. sumifs with mulitple columns and mulitple criteria in each column
    By bkaufman in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 07-18-2012, 05:11 PM
  5. Importing Mulitple Text Files into their respective Cells
    By polishalice in forum Excel General
    Replies: 0
    Last Post: 01-14-2008, 12:13 PM
  6. [SOLVED] Macro to create mulitple files
    By Consulting Joan in forum Excel General
    Replies: 1
    Last Post: 02-07-2006, 11:45 PM
  7. Replies: 4
    Last Post: 10-03-2005, 05: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