+ Reply to Thread
Results 1 to 14 of 14

How to split and export a table into multiple, dynamically named, csv files

  1. #1
    Registered User
    Join Date
    02-09-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    22

    How to split and export a table into multiple, dynamically named, csv files

    Hi,

    Using VBA, I'm familiar with exporting the contents of an entire worksheet to a csv file but can someone help demonstrate how to export sections of a worksheet (see mtable.csv attached) into multiple csv tables named after the symbol name in column A and where the number of rows for each table differs? Ie the end result splitting mtable.csv is the following files (attached)... AA.csv, AAPL.csv and ACN.csv.

    Thanks in advance
    Attached Files Attached Files

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

    Re: How to split and export a table into multiple, dynamically named, csv files

    Assuming "mtable.csv" is also a true csv file.
    Select "mtable.csv", when the code asked.

    To a new workbook.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-09-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: How to split and export a table into multiple, dynamically named, csv files

    That's great jindon, thank you. If the name of the csv file (variable "e" in the above code) is located in another column (say Column B instead of Column A) how would you declare that?

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

    Re: How to split and export a table into multiple, dynamically named, csv files

    Try change to
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-09-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: How to split and export a table into multiple, dynamically named, csv files

    Thank again that works. One last request, how would I include a header row (row 1 of mtable.csv) in each file?

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

    Re: How to split and export a table into multiple, dynamically named, csv files

    Not tested.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-09-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: How to split and export a table into multiple, dynamically named, csv files

    Nearly there, this results in blank rows inserted:

    Attachment 334083

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

    Re: How to split and export a table into multiple, dynamically named, csv files

    No attachment...

  9. #9
    Registered User
    Join Date
    02-09-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: How to split and export a table into multiple, dynamically named, csv files

    sorry, try this:
    [URL deleted]
    Last edited by trilliansounds; 07-22-2014 at 06:22 PM. Reason: orphaned URL

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

    Re: How to split and export a table into multiple, dynamically named, csv files

    I need to see the main csv and the result that you want like you have uploaded in your first post.

  11. #11
    Registered User
    Join Date
    02-09-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: How to split and export a table into multiple, dynamically named, csv files

    Here's the new source table with the filename now in Column B:
    mtable-with header.csv

    Current result:
    AA-current output.csv
    AAPL-current output.csv
    (etc...)

    And desired outcome:
    AA-desired result.csv
    AAPL-desired result.csv
    (etc...)

    Thanks

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

    Re: How to split and export a table into multiple, dynamically named, csv files

    Fixed header?
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    02-09-2010
    Location
    London
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: How to split and export a table into multiple, dynamically named, csv files

    perfect, thank you!

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

    Re: How to split and export a table into multiple, dynamically named, csv files

    That's good and thanks for the rep.

    Can you mark this thread as "Solved"?

+ 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. split text files stored in some location to multiple files based on a condition
    By GIRISH_KH in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-01-2013, 11:32 AM
  2. Split and export Excel data to .txt files
    By Sparrow99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2013, 03:02 AM
  3. Split data from one excel spreadsheet and export to multiple text files
    By jmsavage in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2012, 05:30 AM
  4. dynamically linking multiple identical structured files
    By perinouk in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-12-2007, 08:09 AM
  5. split it into groups of 100 and export it to separate .csvs or text files
    By Shaunclippo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-03-2006, 01:40 PM

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