+ Reply to Thread
Results 1 to 6 of 6

Combining multiple xlsx files into one master file

  1. #1
    Registered User
    Join Date
    06-30-2020
    Location
    NY, USA
    MS-Off Ver
    10
    Posts
    3

    Combining multiple xlsx files into one master file

    Hello,

    I'm have a problem with updating my current VBA code that produces a master file with data from xlsx files in the same folder.

    My current code combines all xlsx files data into one Master file, but I need to add an extra column that would display the original file names in each rows of the combined Master file, so one can determine which data belongs to which file.

    Also my VBA code currently brings over headers for each of the files, and I would like to only have the first files header, and remove all sequential header from the Master.

    If someone can please help, that would be amazing!

    Below is my current code:

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,242

    Re: Combining multiple xlsx files into one master file

    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 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. As you are new here, I have done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    06-30-2020
    Location
    NY, USA
    MS-Off Ver
    10
    Posts
    3

    Re: Combining multiple xlsx files into one master file

    Sorry about that, and thank you very much!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,539

    Re: Combining multiple xlsx files into one master file

    Why not just amend the data range, dataRangeStr = "A1:R250" after the first copy ... just change it to dataRangeStr = "A2:R250"

    So, modify this

    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    06-30-2020
    Location
    NY, USA
    MS-Off Ver
    10
    Posts
    3

    Re: Combining multiple xlsx files into one master file

    Thank you for that!

    The problem is, the original workbooks are not all the same length, so when I make the change you suggest, it removes the repeating headers, but adds significant gaps of empty rows between the combined datasets in the master.

    Also, was hoping to add an extra column for the original file names added to Master.

    Thanks again!
    Last edited by aaronrayev; 06-30-2020 at 11:22 AM.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,539

    Re: Combining multiple xlsx files into one master file

    You're welcome. Thanks for the rep.

    The problem is, the original workbooks are not all the same length, ...
    Not aware that was mentioned in the OP and doesn't seem to be catered for in the current code.

    I'd add the file name for the file on the first entry for each file (in the next available column) and gap fill at the end.

+ 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. Replies: 0
    Last Post: 01-14-2016, 03:22 PM
  2. Replies: 4
    Last Post: 10-04-2015, 08:21 AM
  3. Combining Data from Multiple .xlsx Files with Multiple Sheets
    By jeannelee94 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2015, 10:03 AM
  4. Combining Data from Multiple Excel Files into One Master Sheet
    By glennchung in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-12-2014, 06:28 PM
  5. Replies: 3
    Last Post: 01-05-2014, 05:50 AM
  6. Replies: 1
    Last Post: 12-21-2011, 11:00 AM
  7. Replies: 4
    Last Post: 09-22-2010, 01:22 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