+ Reply to Thread
Results 1 to 17 of 17

Export data from multiple sheets into a new sheet

  1. #1
    Registered User
    Join Date
    11-15-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    24

    Exclamation Export data from multiple sheets into a new sheet

    Hi,

    Can anyone help me out! I need to create a macro that will copy certain cells from different sheets and create a new sheet with all the data stacked.
    Last edited by snoopyngd; 11-25-2010 at 06:17 AM.

  2. #2
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    455

    Re: Export data from multiple sheets into a new sheet

    Quote Originally Posted by snoopyngd View Post
    Hi,

    Can anyone help me out! I need to create a macro that will copy certain cells from different sheets and create a new sheet with all the data stacked.
    hey mate have you tried the macro recorder function? I'm doing something similar on this post: http://www.excelforum.com/excel-prog...-recorder.html

    are you trying you trying to paste many sheets data into one sheet? If so i read about using the consolidating function. Data, Consolidate may help.

  3. #3
    Registered User
    Join Date
    11-15-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Export data from multiple sheets into a new sheet

    Hi,

    Thanks for reply. I tried recording, but the problem is I have varying number of sheets in different workbooks. But I ned the Macro to do the same thing on all of them.
    So I want it to gather the data from the same cells and create a new sheet with the data stacked, but the number of sheets is unknown.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export data from multiple sheets into a new sheet

    You can declare the worksheet where all this data is supposed to collect so that you can refer to it anytime you want from any other workbook while the macro runs.
    Please Login or Register  to view this content.


    You can open all the workbooks in a single folder one at a time like so:
    Please Login or Register  to view this content.


    You can cycle through all the worksheets in the currently active workbook like so:
    Please Login or Register  to view this content.


    You can put all that together to open all the wbs in a single folder and add data row by row into your report sheet.

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    11-15-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Export data from multiple sheets into a new sheet

    Jerry,

    Thanks for reply, that was helpful.

    Using your code for a single workbook to copy data from worksheets into the Report sheet, I found that the data is copied into the same cells. So data from different sheets is copied into the same cells. And I wanted the data from the first sheet to be copied into the Report sheet, then the data from the Second sheet to be copied to the cells below and etc.?

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export data from multiple sheets into a new sheet

    You didn't look closely enough at the FINAL macro where we introduced the NextRw variable. That's how we're controlling using only one row at a time, then incrementing to the nextrow each time we end the loop.

    Check out the syntax of the For Each Ws section in that final macro, too. It uses that nextrow variable.

  7. #7
    Registered User
    Join Date
    11-15-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Export data from multiple sheets into a new sheet

    Jerry,

    Thanks a lot for your replies! They really are helping in understanding the VBA.

    I was trying to use your code on my Workbook and I am struggling to get the right result. Can you please review the files I've attached and help me with the code.
    Basically what I need is a macro for Reports Monthly.xls file that creates a similar "Summary" worksheet as in Example.xls file. The sheet is a summary of data from other worksheets and stacks the data one on the other. The difference is that in Example.xls file the data is reported in years and in Reports Monthly.xls the data is monthly.
    My problem was that the data has different number of columns in different sheets. And I need the data to be copied only until the "Total" column.
    Last edited by snoopyngd; 11-25-2010 at 06:16 AM.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export data from multiple sheets into a new sheet

    Try this:
    Please Login or Register  to view this content.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export data from multiple sheets into a new sheet

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  10. #10
    Registered User
    Join Date
    11-15-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Export data from multiple sheets into a new sheet

    Thanks very much Jerry, you are trully a GURU!

  11. #11
    Registered User
    Join Date
    11-15-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Export data from multiple sheets into a new sheet

    Jerry,

    Hoep you 're fine. Can you help me out with the code for the same example as above, but now I need to copy all of the data including the Total values?

  12. #12
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export data from multiple sheets into a new sheet

    I wouldn't include that column. The information in it is wrong. On the Brenda sheet, put this formula in FJ10 and copy down, you'll see what I mean:

    =SUM($C10:FH10)

  13. #13
    Registered User
    Join Date
    11-15-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Export data from multiple sheets into a new sheet

    Quote Originally Posted by JBeaucaire View Post
    I wouldn't include that column. The information in it is wrong. On the Brenda sheet, put this formula in FJ10 and copy down, you'll see what I mean:

    =SUM($C10:FH10)
    I see what you mean. But the problem is that I might be given data without the Total column or with correct values and the code doesn't work in that case.

  14. #14
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export data from multiple sheets into a new sheet

    You mean the fact that the macro skips sheets without a TOTAL column doesn't work for you? I can change that pretty easily, but including the total column with bad data is a bad idea. Much better to simply ADD a correct TOTAL column on the summary when you're done.

  15. #15
    Registered User
    Join Date
    11-15-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Export data from multiple sheets into a new sheet

    Quote Originally Posted by JBeaucaire View Post
    You mean the fact that the macro skips sheets without a TOTAL column doesn't work for you? I can change that pretty easily, but including the total column with bad data is a bad idea. Much better to simply ADD a correct TOTAL column on the summary when you're done.
    Previous macro works perfect! It is the fact that I might be asked to include the Total column in the summary that makes a problem. That why I would like to have a macro for two different cases. And I can generate the correct Total column anytime.

  16. #16
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Export data from multiple sheets into a new sheet

    This will process all sheets regardless of whether the TOTAL column is present, so no more sheets being skipped. It also automatically adds the correct totals in a column to the far right.

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    11-15-2010
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    24

    Re: Export data from multiple sheets into a new sheet

    Wow great job! It works perfectly! Thanks Jerry!

+ 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