+ Reply to Thread
Results 1 to 10 of 10

Consolidation several tabs' data into a consolidation sheet via a loop?

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

    Consolidation several tabs' data into a consolidation sheet via a loop?

    Hi all,

    I was hoping someone could help me with some loop code for below consolidation macro.

    My workbook has a "Consolidation" tab and several country tabs (all same format). My code consolidates all of the individual country tabs (after a filter is applied), one below the other in the consolidation tab.

    Below code works for 2 countries but there will be 20+ country tabs.

    I'm hoping someone can tweak my code so it can loop through all the country tabs rather than having to duplicate the code over and over like below.


    Please Login or Register  to view this content.
    Last edited by Gti182; 07-30-2015 at 08:13 AM.

  2. #2
    Forum Contributor
    Join Date
    05-27-2014
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    2007 & 2010
    Posts
    273

    Re: Consolidation several tabs' data into a consolidation sheet via a loop?

    How does this work for you?

    EDIT: Added a "Select Case" statement so you can add the names of the tabs you want to copy in case there are more tabs than just country tabs. This also makes sure the "Consolidation" tab is not included (if your name's not down, you're not coming in!)

    Please Login or Register  to view this content.
    Last edited by kadeo; 07-30-2015 at 07:24 AM.
    Please click *Add Reputation if I've helped

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

    Re: Consolidation several tabs' data into a consolidation sheet via a loop?

    wow that looks neat!

    getting a runtime error 1004 Autofilter method of Range class failed on below part of code?
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Consolidation several tabs' data into a consolidation sheet via a loop?

    Maybe:

    Please Login or Register  to view this content.

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

    Re: Consolidation several tabs' data into a consolidation sheet via a loop?

    Hi John that works a treat! Any way to just paste special values?

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Consolidation several tabs' data into a consolidation sheet via a loop?

    Did you only the visible cells in the range? Try:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    05-27-2014
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    2007 & 2010
    Posts
    273

    Re: Consolidation several tabs' data into a consolidation sheet via a loop?

    I seem to remember something about having to activate a sheet before the filter works properly when looping through sheets. Just insert
    Please Login or Register  to view this content.
    into the line above where LR is calculated, within the case in my code see if that works.

    Also, the code you pasted back is still working on DEN instead of wSheet.
    Last edited by kadeo; 07-30-2015 at 08:07 AM.

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

    Re: Consolidation several tabs' data into a consolidation sheet via a loop?

    thanks kadeo and John both work great!

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Consolidation several tabs' data into a consolidation sheet via a loop?

    You're welcome. Glad to help out and thanks for the feedback.

  10. #10
    Forum Contributor
    Join Date
    05-27-2014
    Location
    Belfast, Northern Ireland
    MS-Off Ver
    2007 & 2010
    Posts
    273

    Re: Consolidation several tabs' data into a consolidation sheet via a loop?

    Quote Originally Posted by Gti182 View Post
    thanks kadeo and John both work great!
    A pleasure!

+ 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. [SOLVED] Help for enhance the code - Excluding Sheet While Consolidation
    By ExcelUser2707 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2014, 05:43 AM
  2. Copy data from header to header in consolidation sheet
    By Ignesh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-12-2013, 04:10 AM
  3. Work Sheet consolidation Macro
    By jwbeaty in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2011, 04:05 AM
  4. Consolidation of workbooks in the same file to a single sheet in a master
    By Jaspabl in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-25-2011, 12:11 AM
  5. sheet 1 needs to be daily consolidation of others
    By m3site in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-17-2011, 11:34 AM
  6. Buggy Sheet Consolidation Behaviour
    By shockeroo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2010, 07:42 AM
  7. [SOLVED] Multiple consolidation sheet
    By Navin in forum Excel General
    Replies: 0
    Last Post: 03-15-2006, 11:10 AM

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