+ Reply to Thread
Results 1 to 13 of 13

Need to Merge Data of Multiples Excel Files Together Using VBA

  1. #1
    Registered User
    Join Date
    04-18-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    25

    Need to Merge Data of Multiples Excel Files Together Using VBA

    Hi everyone!

    I need to create an Excel macro using VBA which can merge more than one excel files keeping headers, columns and sheets.
    Two files are attached as examples which need to be merged into one. Format of both files is same.
    Every week I get such new file so I need a Macro to add data of the file to previous ones and hence final file at time of running macro should include data of all files merged together.

    I have been able to create following code but unable to proceed further successfully.

    Please Login or Register  to view this content.
    Any help or guidance will be appreciated in this regard !

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    There is a free Excel Add-In that may do what you want.

    RDBMerge, Excel Merge Add-in


    Here is source code you may find useful.

    Merging Data from Multiple Workbooks
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,944

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    Use a macro like this, and choose the new weekly file in the dialog. If you need to select more than one, the code can loop through all the files that you select in the dialog.


    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  4. #4
    Registered User
    Join Date
    04-18-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    25

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    Hi AlphaFrog,
    Thank you. These are all really helpful links.

    Hi Bernie,
    Thank you so much. Your code surely fulfills purpose of merging files but for first sheet only, if I am right?. How this code can be modified if all sheets are needed to be merged respectively?

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,944

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-18-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    25

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    Hi Bernie,
    Thank you. Your code merges data of all sheets of a single file into one sheet. However my requirement is to merge data of each similar named sheet of each file.
    For example, data in each 'Products' named sheet of both previously attached files/workbooks need to be merged into one and so on with each sheet.
    Excuse me if I wasn't clear in my previous post.

  7. #7
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,944

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    Simple change - as long as the sheets already exist:


    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-18-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    25

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    Hi Bernie,

    Your updated code works fine as far as merging data is concerned but somehow I am unable to select more than one file in the dialog box. Can you please check again?

    Thanks!

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,944

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    It wasn't written to open more than one because you wanted to merge two files into one, which only requires opening one. This version will process as many files as you choose:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    04-18-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    25

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    Thank you so much Bernie. This worked like a charm!

  11. #11
    Registered User
    Join Date
    04-18-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    25

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    Hi Bernie,

    In the same file, now I need to create different files (one per category ID) containing all details from main file. As you can see, main file has many rows and many tabs (containing different category ID). The macro when run should return many files (one per category ID) containing rows and tab, for example:

    Category ID 256 one file with all related products and tabs
    Category ID 45 one file with all related products and tabs
    Categori ID ...........

    Looking forward for quick response. Thanks!

  12. #12
    Registered User
    Join Date
    04-18-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    25

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    Any response would be appreciated please!
    Thank you!

  13. #13
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,944

    Re: Need to Merge Data of Multiples Excel Files Together Using VBA

    I did not download your file, nor will I. My code works with any structure.

    To export to separate files based on a specific value in a field, use code like this (see the comments to modify to your needs):

    Please Login or Register  to view this content.

+ 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] Marge data inside Master workbook getting data multiples files based specfic sheets
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-22-2021, 07:14 AM
  2. Replies: 3
    Last Post: 04-11-2013, 04:27 AM
  3. Merge/Combine Excel Sheets/Data/Files
    By nay in forum Excel General
    Replies: 0
    Last Post: 04-06-2009, 11:35 PM
  4. Macro to copy data from multiples files
    By p1rate78 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-06-2009, 05:35 PM
  5. Need to merge two data files...
    By ositoprincipal in forum Excel General
    Replies: 4
    Last Post: 10-06-2008, 10:10 PM
  6. [SOLVED] Need to Merge Two Excel Data Files
    By la90292 in forum Excel General
    Replies: 0
    Last Post: 10-10-2005, 03:05 PM
  7. merge data from 2 Excel files
    By Maileen in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-18-2005, 10:06 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