Closed Thread
Results 1 to 22 of 22

Merge Multiple CSV files to one XLS with multiple tabs

  1. #1
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Merge Multiple CSV files to one XLS with multiple tabs

    I know there are ways out there somewhere but im having the hardest time finding it.

    I have multiple CSV files.
    All CSV files in the same folder.
    All with different file names
    All with a single tab in them, the tabs are labeled with the file name. (ABC.csv has a single tab in it called ABC).


    How can i merge all the CSV files into a single XLS file where all the CSV files are on their own seperate sheet tab?
    Last edited by PY_; 08-19-2010 at 02:25 PM.

  2. #2
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    Depends on how many, if it's less than 100, quickest way is to open them all, then right-click the sheet tab in one - move or copy - move to some chosen one, repeat for all others except your chosen workbook.

    You will need to save as (not save) and save as an excel workbook not csv, csvs can only be one 'sheet'


    If it's more, a macro would be more appropriate but I'll wait to hear on that...

    hth
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

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

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    I wrote this a couple days ago for someone in another thread. Just edit the fPath to where the CSV files are stored.
    Please Login or Register  to view this content.
    Published on my site here:
    CSVs to Sheets
    Last edited by JBeaucaire; 05-14-2013 at 09:31 AM. Reason: Final edits to the code.
    _________________
    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!)

  4. #4
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    Quote Originally Posted by JBeaucaire View Post
    I wrote this a couple days ago for someone in another thread. Just edit the fPath to where the CSV files are stored.

    That worked beautifully! Thank you so much for the help.

  5. #5
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    Any idea how i can make it run in XL 07? XL03 runs fine but i get this in 07:


    Runtime error 1004

    Cannot insert the sheets into the destination because it contains fewer rows and columns than the source workbook?

  6. #6
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    Your original workbook (into which you are importing needs to be XL07 (i.e. xlsm)).

    .xls files can't have as many rows & columns as your source data (evidently...)

  7. #7
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    2003 it is then for this process.

    Thanks for the tip.

  8. #8
    Registered User
    Join Date
    10-17-2012
    Location
    kingman,wa
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    Used this macro in excel 2010, worked like a charm...this is exactly what I was looking for. Thanks!

  9. #9
    Registered User
    Join Date
    01-24-2013
    Location
    Armenia
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question Re: Merge Multiple CSV files to one XLS with multiple tabs

    Hi, there, I want to merge excel files in one folder into a new created excel folder.
    is there a way to do them automatically?
    if it is possible write me a code in java as opposed as macros. thanks in advance.

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  11. #11
    Registered User
    Join Date
    02-24-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    Thanks Jerry, It worked perfectly!!

  12. #12
    Registered User
    Join Date
    05-14-2013
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    That's great code!! It helps me so much in my project and I can have much more time to work on other things. Thanks for your help

  13. #13
    Registered User
    Join Date
    07-02-2014
    Location
    india
    MS-Off Ver
    2010
    Posts
    3

    Question Re: Merge Multiple CSV files to one XLS with multiple tabs

    Quote Originally Posted by drmoo123 View Post
    Used this macro in excel 2010, worked like a charm...this is exactly what I was looking for. Thanks!

    Can You please help me , when I am trying to run Macro (XL 2010)with Suggested Code , Nothing Happen !!

    Thanks in Advance.

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

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    The original code includes a line of code:
    Please Login or Register  to view this content.
    Make sure you edit that to point to the folder where your CSV files are before you run the macro, and when you edit, remember to leave the final \ at the end.

    If that doesn't work, start a new thread of your own, post your version of the code in that thread for any helpers to see.

  15. #15
    Registered User
    Join Date
    08-29-2016
    Location
    Nottingham, England
    MS-Off Ver
    365
    Posts
    1

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    I've just found this 10 years on from the original post and it works perfectly. Thank you.

  16. #16
    Registered User
    Join Date
    10-02-2017
    Location
    india
    MS-Off Ver
    2010
    Posts
    1

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    This works fine :-) But I want to add all the data in the new workbook, not in the current workbook please guide me

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    murthycode welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  18. #18
    Registered User
    Join Date
    01-22-2018
    Location
    USA
    MS-Off Ver
    O365
    Posts
    1

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    First of all - Thank you for your work!

    I am using Office 2016 via O365

    When I run this macro, it finds all of the CSV files, but opens them in separate workbooks rather than a single workbook/separate tabs

    Thanks again for the help!

  19. #19
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,610

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    alterkation,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

  20. #20
    Registered User
    Join Date
    03-14-2018
    Location
    Houston
    MS-Off Ver
    O365
    Posts
    1

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    Yes it sure does work perfectly! 11 years on.

  21. #21
    Registered User
    Join Date
    05-07-2018
    Location
    Canada
    MS-Off Ver
    Mac 2016
    Posts
    3

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    Hi everyone,

    How can I get this code running on Excel for Mac 2016?

  22. #22
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Merge Multiple CSV files to one XLS with multiple tabs

    rsm21 welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

Closed 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