+ Reply to Thread
Results 1 to 13 of 13

Combine multiple .csv, .ods, .xlsx files in a single workbook

  1. #1
    Registered User
    Join Date
    05-01-2014
    Location
    Waco, TX
    MS-Off Ver
    MS Office 365
    Posts
    30

    Combine multiple .csv, .ods, .xlsx files in a single workbook

    Hello,

    I have the following workbook with a vba code that will combine files on an individual tab in an excel workbook.

    Is it possible to have this recognize .csv files? and possibly even .ods as well?

    Thank you!

    Patrick
    Attached Files Attached Files
    Last edited by PC41; 09-17-2021 at 04:19 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,859

    Re: Combine multiple .csv files in a single workbook

    Look at the Power Query Option.

    https://www.youtube.com/watch?v=K-nal4mlVq8

    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-01-2014
    Location
    Waco, TX
    MS-Off Ver
    MS Office 365
    Posts
    30

    Re: Combine multiple .csv files in a single workbook

    Thank you Alan,

    In the example given in the youtube video I believe the files have only one tab that are all formatted the same. In the files we receive from there are multiple tabs.

    How would I choose to extract just the tab titled report from each file? Usually we combine them all with original attached macro, delete the extra tabs then, run a separate macro to combine all the sheets.

    Also, it does not seem to work for .ods (open office) file types. I have attached a few example files where I would only combine the report tab.
    Attached Files Attached Files

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,859

    Re: Combine multiple .csv files in a single workbook

    A bit confused here. You indicated in your original post that the files were CSV which means there should not be any tabs. Please clarify. As to the ODS files, they would need to be converted to xlsx first. There is not currently available the abiltiy to bring ODS directly into the PQ Editor. Once you clarify the CSV issue/question, I will address the Tab issue..

  5. #5
    Registered User
    Join Date
    05-01-2014
    Location
    Waco, TX
    MS-Off Ver
    MS Office 365
    Posts
    30

    Re: Combine multiple .csv files in a single workbook

    Sorry Alan,

    I should have been more clear. I was wondering if the VBA code in the original post could be tweaked to also show .csv & .ods files in the selection menu. It currently will only allow selection of xlsx, xls & xlsm. I have pasted the code below. Also, thank you for showing me the power query function. I look forward to researching this more and I believe this will help with a separate task that I currently do related only to csv.

    Code:

    Please Login or Register  to view this content.
    Last edited by PC41; 09-21-2021 at 09:41 AM.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,859

    Re: Combine multiple .csv files in a single workbook

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

  7. #7
    Registered User
    Join Date
    05-01-2014
    Location
    Waco, TX
    MS-Off Ver
    MS Office 365
    Posts
    30

    Re: Combine multiple .csv files in a single workbook

    I have updated VBA code w/ proper formatting

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Combine multiple .csv files in a single workbook

    This would provide you with the three file type options in the drop down:

    Please Login or Register  to view this content.
    Rory

  9. #9
    Registered User
    Join Date
    05-01-2014
    Location
    Waco, TX
    MS-Off Ver
    MS Office 365
    Posts
    30

    Re: Combine multiple .csv files in a single workbook

    Thank you @rorya, but it still doesnt seem to be allowing me to select ods and csv in the menu when I run the macro. Please see macro menu prompt vs the actual file location below.

    File explorer folder w/ .ods, .csv, xlsx files:
    Attachment 748142

    Macro file choice menu:
    Attachment 748143
    Last edited by PC41; 09-17-2021 at 05:52 PM.

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Combine multiple .csv, .ods, .xlsx files in a single workbook

    Your attachment doesn't work. The dropdown in the file picker should have three different options in it.

  11. #11
    Registered User
    Join Date
    05-01-2014
    Location
    Waco, TX
    MS-Off Ver
    MS Office 365
    Posts
    30

    Re: Combine multiple .csv, .ods, .xlsx files in a single workbook

    @rorya I tried opening the attachment from the original post, ran the macro and it worked. It opens file explore menu and then lets you select individual files and combines all tabs from selected files into a single workbook. It just wont recognize ods or csv even though they are in the location. I think in the code I pasted may not have had the code tags around everything.

    Please Login or Register  to view this content.

  12. #12
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Combine multiple .csv, .ods, .xlsx files in a single workbook

    It sounds like you want all options available at once rather than being able to switch between the three, in which case what you need is just something like:

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    05-01-2014
    Location
    Waco, TX
    MS-Off Ver
    MS Office 365
    Posts
    30

    Re: Combine multiple .csv, .ods, .xlsx files in a single workbook

    It is working. Thank you so much!

+ 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. [SOLVED] Combine multiple files using the sheet name into new workbook
    By Jimmy1709 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-11-2019, 10:35 AM
  2. [SOLVED] Combine multiple workbooks into single workbook
    By carlito2002wgn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2019, 09:19 PM
  3. How to combine multiple workbooks in a single workbook.
    By sac0011 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-12-2014, 09:12 AM
  4. [SOLVED] Macro to Combine Multiple Workbook Data into Single Target Workbook
    By Jimbo42 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2014, 08:26 PM
  5. Replies: 2
    Last Post: 06-17-2014, 11:16 AM
  6. Replies: 0
    Last Post: 11-28-2013, 12:03 PM
  7. Combine multiple workbooks into one single workbook
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-23-2010, 09:38 PM

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