+ Reply to Thread
Results 1 to 13 of 13

Copying Multiple worksheets in Multiple workbooks to one single workbook

  1. #1
    Registered User
    Join Date
    09-12-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    10

    Copying Multiple worksheets in Multiple workbooks to one single workbook

    I am having some problems trying to get this to work. It appears to be working partially but not fully and I am at a loss right now and would appreciate any help you could give me. I am trying to open up several files within one folder. There are 3 files per day that are saved into the folder. The folder corelates to the month. So for September I have 65 different files I want to open up. I only want to copy the information from A7:A20, C7:C20, and D7: D20. All fields may not be completely filled in all the time and may be left blank. I then want to have it take this information and put it on the workbook in which I am running the code. Here is the code I have so far. Does anyone have any suggestions or help that they could give me.

    HTML Code: 
    Here is a screen shot of where I am pulling the information from as well:

    \1

    Thank you in advance,
    Eric
    Last edited by ebrabender; 10-27-2011 at 05:00 PM.

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

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    Instead of the screenshot, it will be good if you can attach a sample workbook or workbooks so that we can test your code along with the file.

  3. #3
    Registered User
    Join Date
    09-12-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    I am not sure how I would attach a workbook. Do you mean just what I have on my screen shot but multiples of them? I am okay giving out the actual workbook

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

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    To attach a file to your post, you need to be using the main 'New Post' or 'New Thread' page and not 'Quick Reply'. To use the main 'New Post' page, click the 'Post Reply' button in the relevant thread.

    On this page, below the message box, you will find a button labelled 'Manage Attachments'. Clicking this button will open a new window for uploading attachments. You can upload an attachment either from your computer or from another URL by using the appropriate box on this page. Alternatively you can click the Attachment Icon to open this page.

    To upload a file from your computer, click the 'Browse' button and locate the file. To upload a file from another URL, enter the full URL for the file in the second box on this page. Once you have completed one of the boxes, click 'Upload'.

    Once the upload is completed the file name will appear below the input boxes in this window. You can then close the window to return to the new post screen.

  5. #5
    Registered User
    Join Date
    09-12-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    Here are a couple sample workbooks. I only want to pull of the Corr2 sheet for this one then I will setup another one to pull off of the Corr3 sheet.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    09-12-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    I seem to be close with the above code. However, I am noticing that it isn't pulling all of the data from all of the files within the folder in which they are and am not sure as to why. I notice that when the program itself is running it isn't pulling the files in order from start to finish that is it bouncing around a bit.

  7. #7
    Registered User
    Join Date
    09-12-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    I just confirmed it isn't pulling the files in order from how they are in the folder. Does anyone have any idea as of why? also it didn't pull any information from the very last file that it opened up. It pulled the file fields but not the data that was in the fields. The files are dates from the beginning of the month to the end. I would have assumed it would pull them in order from the first file in the folder till the last. However this is not what is happening.

  8. #8
    Registered User
    Join Date
    09-12-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    Alright I have it all figured out except for one thing. Instead of copying all the data I am pulling into a new workbook I want to open it up in the one I have the macro running in. Does this make sense? Any help would be great.

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

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    Just some observations on your code.

    Instead of this -
    Please Login or Register  to view this content.
    You can ask the user to navigate to the path where the files are saved. This can then be assigned to MyPath. That way you do not have to check if the user has put the last "/". (However, if its too difficult to get this done, you can continue with the above).

    I guess this is where your copied data is getting stored. -
    Please Login or Register  to view this content.
    You can change it to refer to your macro workbook like -
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    09-12-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    Yes that is where it is being stored. How do I change that to refer to my macro workbook? I figured everything else out and it appears to be working properly. Even figured out how to sort the new incoming data. Just trying to figure out how to have Excel put a space in between two fields when one sort stops and the other one begins.

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

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    If
    Please Login or Register  to view this content.
    doesnt work properly, then use
    Please Login or Register  to view this content.
    What do you mean by space? Row to be inserted or column?

  12. #12
    Registered User
    Join Date
    09-12-2011
    Location
    Wisconsin
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    A row due to the way I am sorting data out. The only question I have is I have a lot of other code about the new workbook in the original. When I change the BaseWks=thisworkbook Do I need to change any of my other programming after that line?

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

    Re: Copying Multiple worksheets in Multiple workbooks to one single workbook

    If you are referring to the new workbook as BaseWks throughout, you do not have to change it.

    To insert a blank row, just add 1 to this code line -
    Please Login or Register  to view this content.
    Change it to -
    Please Login or Register  to view this content.
    This will leave one row and then copy the next file's data onto the next row.

+ 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