+ Reply to Thread
Results 1 to 31 of 31

Macro copy data from multiple workbooks to master sheet

  1. #1
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Macro copy data from multiple workbooks to master sheet

    Hi,

    need macro to copy data from multiple workbook to master sheets.
    Happy to Help

    VISHA

    Click *, if the suggestion helps you!
    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>> "Mark your thread as Solved"

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Macro copy data from multiple workbooks to master sheet

    Hi Visha.

    Post a sample file
    Click *, if my suggestion helps you. Have a good day!!

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

    Re: Macro copy data from multiple workbooks to master sheet

    A few questions -

    Are these workbooks having the same headers? Are they stored in one folder? Is it just 1 sheet that needs to be copied or multiple sheets within the workbooks?

    Does the master workbook already exist and data should be appended at the next available row of the master file or should the master workbook be created from scratch?
    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]

  4. #4
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    hi,Arlu

    All these workbooks having the same headers and they stored in one folder and master file is open.

  5. #5
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    Hi,jraj

    please find sample file
    Attached Files Attached Files

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

    Re: Macro copy data from multiple workbooks to master sheet

    Should the data from the attached files be added from the next available row onwards or should the master file be cleared and then fresh data input?

  7. #7
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    Arlu

    yes data file should be added from the next available row one below one, according to all sheets .

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

    Re: Macro copy data from multiple workbooks to master sheet

    Try this code -
    Please Login or Register  to view this content.
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    Choose Insert | Module
    Where the cursor is flashing, choose Edit | Paste

    To run the Excel VBA code:
    Choose View | Macros
    Select a macro in the list, and click the Run button

  9. #9
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    Arlu Thanks for all you help

  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: Macro copy data from multiple workbooks to master sheet

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.

  11. #11
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    hi,Arlu

    your code has run but data has not been copy.

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

    Re: Macro copy data from multiple workbooks to master sheet

    Did you copy the code to the Master file code window?

  13. #13
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    yes i have copied in master file window.

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

    Re: Macro copy data from multiple workbooks to master sheet

    Did you change the file path in the code from
    Please Login or Register  to view this content.
    to the path where your files reside?

    Also ensure that the master file is not in the same path where the files are stored.

  15. #15
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    Hi,Arlu

    pls check after changing the path it not working

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    Its is showing Consolidation complete and Master workbook is Blank??

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

    Re: Macro copy data from multiple workbooks to master sheet

    Change this line from
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    P.S - Please do not bump the thread so many times.
    Last edited by arlu1201; 01-29-2013 at 08:34 AM.

  18. #18
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    Arlu still master file showing blank (Consolidation complete)

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

    Re: Macro copy data from multiple workbooks to master sheet

    Can you upload your master file after running the macro? I will use the earlier file you upload as the "before running macro" file.

    I ran the macro at my end and it works.

  20. #20
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    Please find attached
    Attached Files Attached Files

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

    Re: Macro copy data from multiple workbooks to master sheet

    If you have put the macro in the master file, you should save it as a .xlsm file not .xlsx.

  22. #22
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    Path = z:\visha.h\courier folder for -all file

    path = z:\visha.h\idbi for -courier report master


    Hope now u help me

    thanks
    Attached Files Attached Files

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

    Re: Macro copy data from multiple workbooks to master sheet

    You are not understanding what i am saying. You have to save the macro in the Courier Report Master file and save the file as a .xlsm file. Check under the file save as options.

    This is not the solution to the problem but just one point that i need to bring to your notice.

    I am checking the code along with the files right now.

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

    Re: Macro copy data from multiple workbooks to master sheet

    All your data is getting consolidated into the "TAT" sheet of your file which is hidden.

    Try this updated code -
    Please Login or Register  to view this content.

  25. #25
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    hi,Arlu

    sorry to disturbing you again again

    i have save file in .xslm but again showing (Consolidation complete) and file blank.
    Attached Files Attached Files

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

    Re: Macro copy data from multiple workbooks to master sheet

    Did you read the comment in post 24 and try the updated code?

  27. #27
    Forum Contributor visha_1984's Avatar
    Join Date
    11-27-2012
    Location
    Pune,India
    MS-Off Ver
    Excel 2010
    Posts
    290

    Re: Macro copy data from multiple workbooks to master sheet

    Sorry Arlu

    I got it finally

    Thanku so much once again.

  28. #28
    Registered User
    Join Date
    01-30-2013
    Location
    Los Angelos, California
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Macro copy data from multiple workbooks to master sheet

    I have a very similar problem to solve as visha_1984. I tried to use his excel sheets and data as a practice before setting up my own files. However, I'm getting a "run time error 9, subscript out of range" and the code is not drawing the data into the master workbook. The debugger highlights the line "Set sourceData = sourceBook.Worksheets ("MASTER").
    Is there anything I need to change in the code below to get this to work? I'm pretty new to VBA programming so if someone could include an explanation as to why I'm getting the error along with the solution that would be greatly appreciated. Thank you.


    Please Login or Register  to view this content.
    Last edited by arlu1201; 02-08-2013 at 05:23 AM.

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

    Re: Macro copy data from multiple workbooks to master sheet

    Ghoststark21,

    Check if the name of the source sheet is named as "MASTER". If not, then change it in the code to whatever is the name of your source sheet.

  30. #30
    Registered User
    Join Date
    01-15-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Macro copy data from multiple workbooks to master sheet

    I am using the above macros to copy datas from the different excel files. Unfortunately I am facing a Weird proble.

    I am having three excel files in the folder and each sheet has min 50 entries. When i run the macros I am able to see the only 1 column from the first excel sheet and 2 column from the second excel sheet and 4 coloumn from third excel sheet.

    Can you please help out with this.

    Note: I have changed the path alone in the macros in which you have pasted.


    Thanks

    Vinoth

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

    Re: Macro copy data from multiple workbooks to master sheet

    u767,

    Your data might be differently formatted. Its better you create a thread of your own and attach a sample file. You can link back to this thread by providing a link of this thread in your thread. I will help you there.

+ Reply to 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