+ Reply to Thread
Results 1 to 19 of 19

Copy from other sheets into one sheet

  1. #1
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Copy from other sheets into one sheet

    Hi all,

    I've got the following code, which copies data from other sheets within the same workbook. The idea is to place the data into one table, with the data from the next sheet going into the next empty cell etc etc.

    Please Login or Register  to view this content.
    I've gone wrong somewhere, as it is copying it all into one column (B) as opposed to copying across B, C and D.

    Any ideas?

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,027

    Re: Copy from other sheets into one sheet

    Try: (untested)
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,309

    Re: Copy from other sheets into one sheet

    Possibly...
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Copy from other sheets into one sheet

    Getting a "For without next" error

  5. #5
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Copy from other sheets into one sheet

    I've added in a next, which gets it work but copies everything into one column - which is partly correct. Require data from columns C and D to be copied from the CPA worksheets into the Shared Contact Pivot worksheet.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,027

    Re: Copy from other sheets into one sheet

    Which macro are you referring to, the one I suggested or the one suggested by dangelor? Can you attach a copy of your file with the desired result in the "Shared Contact Pivot" sheet?

  7. #7
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Copy from other sheets into one sheet

    I have attached a test copy of my workbook. The first 3 tabs are how they look in my actual workbook, with the yellow one showing the desired result.

    As the data in any of the CPA tabs (There are 10 on my actual workbook) could be anything between 2 and 2000 rows worth of data, I need the code to be dynamic and copy from CPA 1 into the Shared Contact Pivot sheet, then copying CPA 2 underneath that and so on.

  8. #8
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Copy from other sheets into one sheet

    Attached test workbook
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Copy from other sheets into one sheet

    Perhaps
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Copy from other sheets into one sheet

    Thanks jindon, that worked perfectly! There are 10 CPA tabs, sometimes there will only be data in 2 or 3, so the others will be blank. When running this code it takes the headers from the blank CPA tabs and copies it into the Shared Contact Pivot. Is there a way to avoid this?

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Copy from other sheets into one sheet

    Try
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Copy from other sheets into one sheet

    Perfect! Thank you

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Copy from other sheets into one sheet

    You are welcome and thanks for the rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  14. #14
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Copy from other sheets into one sheet

    Hi Jindon,

    I have added an extra column into Col C.

    How would this now affect the code? Column B remains in the same place, but Columns C and D are now Columns D and E, so the code needs to change to affect those columns.

    Many thanks,

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Copy from other sheets into one sheet

    You want to copy Col.B, Col.E & Col.E?
    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Copy from other sheets into one sheet

    From the sheets entitled CPA 1, CPA 2 etc I want to copy:

    Columns B:E from the second row down

    INTO

    B:E on the Shared Contact Pivot sheet into B2 initially and then CPA 2 into the next blank row and so on...

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Copy from other sheets into one sheet

    Then just change .Resize( ,3) to 4 in the first code.
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    758

    Re: Copy from other sheets into one sheet

    What about to loop through all of the sheets entitled CPA?

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Copy from other sheets into one sheet

    Ooops, it should be the 2nd one...
    Please Login or Register  to view this content.

+ 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. Replies: 19
    Last Post: 08-02-2018, 10:54 PM
  2. Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  3. Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  4. Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  5. Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  6. Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  7. Replies: 1
    Last Post: 07-06-2005, 05: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