+ Reply to Thread
Results 1 to 28 of 28

Copying data from multiple sheets of multiple excel.

  1. #1
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Copying data from multiple sheets of multiple excel.

    Hi Friends,
    I'm working itna Pharma company HR Dept. On a monthly basis, we receive atendance file from different locations. Approximately 27-28 excel files on end of the month count of files may vary month on month. Each excel files contains 7 sheets. Everytime I have to club all the 28 excel files & make it into single excel files with 7 sheets. There is always a chance of missout of data. Is there anyway by using macro I can get this done.

    Pls help.I'm not much familiar with macros.

  2. #2
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Copying data from multiple sheets of multiple excel.

    Hi,
    Welcome to the forum,
    One Clarification.!
    So 28 workbooks with 7 sheets each are to be clubbed in one workbook having seven sheets
    so Sheet 1 in all 28 workbooks are to be clubbed one after one in sheet 1 of Resultant workbook.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Copying data from multiple sheets of multiple excel.

    Hi, BenTenison,

    please have a look at WBs to Sheets or Merge data from all workbooks in a folder or RDBMerge, Excel Merge Add-in for Excel for Windows.

    HTH,
    Holger
    Last edited by JBeaucaire; 12-26-2019 at 04:23 PM.
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Copying data from multiple sheets of multiple excel.

    Hi Here is the code.
    Untested though.
    Put all your 28 Files in one Folder in Drive D: Folder Extracts
    Open the Main File and run this code on it..

    Please Login or Register  to view this content.
    Keep an Eye over Status bar on the left bottom of the screen.
    I have tried something with that.

    EDIT:- Sorry Ben for that small mistake. I have taken care of that. So now you can try it.
    Hi Holger, I do think that third one is a biggi. so I have corrected that.
    Last edited by Vikas_Gautam; 12-14-2014 at 01:53 PM.

  5. #5
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Thanks Vikas.

    That was awesome.....

    I did a dummy check & it worked. Truly awesome

    Thanking you again for the support provided

  6. #6
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Copying data from multiple sheets of multiple excel.

    Thanks for the feedback..
    It was totally untested.
    Actually I wrote it right here..
    I am glad that it worked for you.
    Good Luck

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Copying data from multiple sheets of multiple excel.

    Hi, BenTenison,

    some weaknesses of the Vikas macro:
    - relying on the position of the sheets (not even worksheets) so any change of order will lead to a wrong compilation of data.
    - switching of workbooks which is unnessary
    - having all workbooks still open at the end of the macro.

    I would rather go with the fourth macro from Jerryīs link (the first link I supplied) relying on the sheetnames rather than the index.

    Please Login or Register  to view this content.
    Ciao,
    Holger

  8. #8
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Hi,
    That a very good suggestion. But is it possible to copy data based on the sheet names.

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Copying data from multiple sheets of multiple excel.

    Hi, BenTenison,

    have a look at PART 4 - Appending Data from All Existing Sheets in all workbooks into a Master Workbook matching the sheetnames. The only thing you might need to add is the addition of a worksheet intoi the masterbook if the names donīt match, I would ask you to clarify on that.

    Ciao,
    Holger
    Last edited by JBeaucaire; 12-26-2019 at 04:24 PM.

  10. #10
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Hi Ciao,
    Thank you,
    It helped a lot. Really superbbb......

  11. #11
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Have deleted the post & started a new thread
    Last edited by BenTenison; 12-15-2014 at 05:39 AM.

  12. #12
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Copying data from multiple sheets of multiple excel.

    Here is the code you are looking for:-
    It is totally untested.

    Please Login or Register  to view this content.
    Edit:- As suggested by Holger.
    Last edited by Vikas_Gautam; 12-19-2014 at 03:21 AM.

  13. #13
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Copying data from multiple sheets of multiple excel.

    Hi, Vikas,

    this is a public forum and as such any information about some errors should be reported here and not being aslked to be reported via PM.

    I think that you respneded to the deleted püost (and the answer should be in the other thread).
    Here is the code you are looking for:
    You should restraint the loops in both workbooks and leave the loop for the new workbook once a Match was found. Iīd rather had used a Set for the corresponding worksheet in the masterbook (new book delivering the sheetname).

    Ciao,
    Holger

  14. #14
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Copying data from multiple sheets of multiple excel.

    Quote Originally Posted by BenTenison View Post
    Have deleted the post & started a new thread
    Why did you feel the need to start a new thread on this?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  15. #15
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    It was a different topic not related to above hence deleted & started a new thread.
    W.r.t above thread "Copying data from multiple sheets of multiple excel." I raised the issue directly with Vikas since he made the codes.
    Pls correct me if there is any issue in my way of approach.

  16. #16
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    When clicked on macro, in background it shows working & at the end it confirms “Finished”. But nothing is copied in excel file. Its totally blank.

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Copying data from multiple sheets of multiple excel.

    OK, not problem. It sounded like you got stuck and just started over

  18. #18
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Copying data from multiple sheets of multiple excel.

    Hi Ben Ten,
    I have just tested the Code:-
    It working perfectly for me without any changes.
    Please Login or Register  to view this content.
    1. The possible reason for the failure can be that the column headers in the MainBook is not matching exactly with headers in the Sub sheets.
    If I comes out to be correct, then we will proceed to correct it as well.

  19. #19
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Extracts.zipExtracts.zip
    Pls find the file

  20. #20
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Tried again. But still the same. Pls help

  21. #21
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Copying data from multiple sheets of multiple excel.

    I have made some changes...
    and its working now..

    Please Login or Register  to view this content.
    Last edited by Vikas_Gautam; 12-20-2014 at 08:49 AM.

  22. #22
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Hi Vijay, Error is showing with msg as
    Runtime Error '1004'. Application-defined or object-defined error

  23. #23
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Hi guys pls help!!

  24. #24
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Cool Re: Copying data from multiple sheets of multiple excel.

    I am sorry Ben,
    It was my mistake..
    Its working now..

    Please Login or Register  to view this content.
    There is a MainBook.xlsm file in Mainbook folder in the attachment.
    Check the attached zip attachment
    Attached Files Attached Files
    Last edited by Vikas_Gautam; 12-22-2014 at 03:22 AM.

  25. #25
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Error.jpgHi Vijay, Th code is working properly but nothing is copied in the file

  26. #26
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Code runs properly but nothing is getting copied in th file

  27. #27
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Copying data from multiple sheets of multiple excel.

    Have you changed the Folder Path...?
    you have to change it with your actual path..

    Edit:- I have Completely rebuild the Code. You can give it a try if you want.
    Please Login or Register  to view this content.
    Last edited by Vikas_Gautam; 01-02-2015 at 02:45 PM.

  28. #28
    Registered User
    Join Date
    12-13-2014
    Location
    India
    MS-Off Ver
    2007
    Posts
    19

    Re: Copying data from multiple sheets of multiple excel.

    Sorry was on paternity leave, hence couldn't get in touch with you. I'm blessed witha Baby Boy. Will try the code & confirm to you

+ 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. Copying data from multiple workbooks having multiple sheets into one master worksheet
    By Navya Ahuja in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-15-2014, 09:42 AM
  2. Replies: 3
    Last Post: 06-20-2014, 05:49 AM
  3. Replies: 0
    Last Post: 11-08-2012, 01:07 PM
  4. Copying Data Range from Multiple Sheets
    By UncleSalty in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-14-2011, 10:11 AM
  5. [SOLVED] Copying data from multiple sheets into one sheet
    By Todd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2005, 11:05 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