+ Reply to Thread
Results 1 to 18 of 18

Combining Data from Multiple Excel Files into One Master Sheet

  1. #1
    Forum Contributor
    Join Date
    01-29-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    123

    Combining Data from Multiple Excel Files into One Master Sheet

    Hi

    I have spent some time searching for help/code online to do this but can't find anything useful. I really hope you can help.

    I need to combine data on 100+ Excel files (all in one folder) with only 1 worksheet in each file into one single master sheet on another file. These Excel files are like forms with data that I want to combine in a single sheet. So all these Excel files will have the same worksheet name and location of data to be combined will be the same throughout, just that the file name would be different.

    I have attached some sample files and hope it will help. If there's a primer that's useful to get me started, great! If there's existing code that requires minor editing, that's even better! I am also open to other ideas on how to automate this.

    Thank you in advance!

    Glen
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,521

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    If there's existing code that requires minor editing
    Does that mean that you prefer to look at it and change it to your needs?
    If so, go through this code and change to your requirements.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-29-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    Ok, let me give this a try and will report back. Thanks!

  4. #4
    Forum Contributor
    Join Date
    01-29-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    Ok, it didn't take very long for me to get stuck. I understand the code except the .Range part.

    How do I do the following?
    • On the first file, copy a single cell from source to a single cell to destination, and on subsequent files, it will be copy to the next row
    • Do the same for a range of data

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,521

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    How do you know if it will be the first file?
    Does that file have a different range to copy (one cell)? Which cell?
    Do you know the name of that file?
    The code example pastes into the first empty cell in column A. Is that where that one cell value (or text) will be pasted?
    What are the ranges you want to copy in all the other files?

  6. #6
    Forum Contributor
    Join Date
    01-29-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    I guess the order of source files is not important, as long as the content is copied over to the master sheet in a table format. Each source file will have exactly the same format.

    So, in my case, I need to copy B2, B4, D2, D4 (plus 30+ other cells) from source files to line them up on a row in the master sheet with each source file content on its own row. I have attached the source file (FileA) and the destination file (Master) with cells to be copied and where they will be pasted.

    Thank you very much for your help!
    Attached Files Attached Files
    Last edited by glennchung; 08-08-2014 at 02:24 PM.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,521

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    Try this on a copy of your workbook.
    Code goes in the "Master" workbook.

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-29-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    This works perfectly! I have a couple more questions and this should wrap it up.
    1. If I want to include a drop-down box for users to select resource type (highlighted in red on the attached), how would you code it to copy numbers according to the resource type selected and only when a resource type is selected? I will still maintain three fixed ranges on the master data sheet with all three resources.
    2. This is not related to #1. How do I include calculations when copying numbers from source data to master data? For example, I want to multiply the "units" row (shown in orange) by "price" in cell D4 and paste it in the destination range. I am guessing I need to use Select Case but not 100% sure.

    Thank you very much, I really appreciate your help!
    Attached Files Attached Files

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,521

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    Instead of copying only certain rows, would it be OK to copy everything and hiding columns of the Resources you don't want to see?
    Can the multiplication be done in the "Master Data" sheet after everything has been copied over?

  10. #10
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,521

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    For the multiplication part, change this

    Please Login or Register  to view this content.
    to this

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,521

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    Hi glennchung
    I had another look at your latest attachment where you have the dropdowns in cells A7, A9 and A11 in the Workbook where the information is copied from.
    Should the dropdown not be in the Master Workbook? After all, you run the code from The Master Workbook.

  12. #12
    Forum Contributor
    Join Date
    01-29-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    The dropdowns will be on the source file and the Master Workbook will just have fixed ranges for data to be copied to. So depending on what the dropdown is on the source file, it will be copied to a fixed location in the Master Workbook. Say if it's Resource 1 on the source file, then copy that specific range of 10 cells to a range in the Master Workbook destinated for Resource 1 (for example, starting from column N, and this won't change). But the same range on the source file can be Resource 1, or Resource 2, or Resource 3 since there's a dropdown to the left. However, all resources will have their fixed columns in the Master Workbook. I hope this will clarify it. Thank you!

  13. #13
    Forum Contributor
    Join Date
    01-29-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    Quote Originally Posted by jolivanes View Post
    Instead of copying only certain rows, would it be OK to copy everything and hiding columns of the Resources you don't want to see?
    Can the multiplication be done in the "Master Data" sheet after everything has been copied over?
    I thought about it but I am trying to keep the Master Workbook small since there will be a lot of source files to pull data in. Thanks for the update!

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,521

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    I thought about it but I am trying to keep the Master Workbook small since there will be a lot of source files to pull data in.
    This is not going to make your file bigger.

  15. #15
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,521

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    How many files could there be where you copy from? In your last post you indicated that there could be a lot.
    In all these files, I assume that Cells B7:K7 is Resource 1, B9:K9 is Resource 2 and B11:K11 is Resource 3.
    In Cells A7, A9 and A11 you have a choice of "Select Resource Type", Resource 1", "Resource 2" and "Resource 3"
    So what needs to be done if Cell A7 has "Resource 3" (should be Resource 1 IMHO), Cell A9 has "Resource 3" (should be Resource 2 IMHO) and in Cell A11 has "Resource 1" (should be Resource 3 IMHO)?
    And what if "Select Resource Type" has been selected? Nothing should happen I assume.
    Also, before you run the code in your "Master" you need to go and open all the workbooks, select whatever you want in your drop downs, save the workbooks and go to your "Master" to run the code.
    As you indicated before that there could be a lot of files, this will end up to be very time consuming and defeats the purpose of using code to speed up the operation.
    Nevermind the real possibility of getting wrong information when the selection in the drop downs is questionable.
    You can run everything from your "Master" if it is set-up properly.
    Let us know how you want to proceed.

  16. #16
    Forum Contributor
    Join Date
    01-29-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    Quote Originally Posted by jolivanes View Post
    How many files could there be where you copy from? In your last post you indicated that there could be a lot.
    There can be over 100 files or even close to 200.

    In all these files, I assume that Cells B7:K7 is Resource 1, B9:K9 is Resource 2 and B11:K11 is Resource 3.
    In Cells A7, A9 and A11 you have a choice of "Select Resource Type", Resource 1", "Resource 2" and "Resource 3"
    So what needs to be done if Cell A7 has "Resource 3" (should be Resource 1 IMHO), Cell A9 has "Resource 3" (should be Resource 2 IMHO) and in Cell A11 has "Resource 1" (should be Resource 3 IMHO)?
    Yes, at first I thought I can keep things simple with just 3 resources and cells B7:K7 would be Resource 1, B9:K9 Resource 2, and B11:K11 Resource 3. But it looks like the total number of labor types can grow now and the number of resources required in one project (one file) would just be a few. So I want to make it flexible for users to select labor type. (Sorry for the change of mind)

    So one file can be just Resource 1 and 2, another file can be just Resource 2 and 3, yet another might just be Resource 3, etc. I have attached a sample to illustrate this. It serves as a snapshot of data flow, so this does not refer to an actual source or master workbook.

    I read that I can use "select case" but I just can't be sure how it can be incorporated into the existing code.

    And what if "Select Resource Type" has been selected? Nothing should happen I assume.
    Yes, nothing would happen, and no data will be copied over for that specific project or source file. (Update: Will it mess up the copy/paste function since the code is looking for the last row of data?)

    Also, before you run the code in your "Master" you need to go and open all the workbooks, select whatever you want in your drop downs, save the workbooks and go to your "Master" to run the code.
    As you indicated before that there could be a lot of files, this will end up to be very time consuming and defeats the purpose of using code to speed up the operation.
    Nevermind the real possibility of getting wrong information when the selection in the drop downs is questionable.
    You can run everything from your "Master" if it is set-up properly.
    Let us know how you want to proceed.
    The source files would be coming from different individuals entering information and selecting resource types for their specific projects; and I will simply be aggregating data into the Master Workbook. So yes, the content in source files can change but I will just re-run the code to pull information.

    I really appreciate you getting to the bottom of this. This will really save my life!

    Please let me know if this is possible.
    Last edited by glennchung; 08-11-2014 at 06:54 PM. Reason: File uploaded, see RED update

  17. #17
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,521

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    Try this on a copy of your workbook.
    If you have a lot of files to be copied from, it might be advised to start the code at lunch time.
    It might be done when you come back from lunch!!!!
    All kidding aside, until someone comes with a better and faster solution, this should do for the time being.
    Good luck


    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    01-29-2009
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    123

    Re: Combining Data from Multiple Excel Files into One Master Sheet

    Thanks jolivanes, appreciate the effort! I will give it a try later today. Thanks.

+ 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. Import datas form multiple excel files to master sheet for consolidation
    By laxmananm in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-06-2014, 11:11 AM
  2. Replies: 2
    Last Post: 02-14-2014, 01:39 PM
  3. Combining data from multiple excel files
    By pknittle in forum Excel General
    Replies: 3
    Last Post: 11-15-2013, 12:53 PM
  4. Combining Multiple Lists Onto One Master Sheet
    By KaneThomas541 in forum Excel General
    Replies: 1
    Last Post: 07-03-2013, 01:07 PM
  5. Combining data from multiple Excel Files
    By robbyvegas in forum Excel General
    Replies: 1
    Last Post: 10-05-2010, 01:29 AM

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