Results 1 to 10 of 10

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

Threaded View

Gti182 Consolidation several tabs'... 07-30-2015, 06:51 AM
kadeo Re: Consolidation several... 07-30-2015, 07:20 AM
Gti182 Re: Consolidation several... 07-30-2015, 07:27 AM
kadeo Re: Consolidation several... 07-30-2015, 08:01 AM
JOHN H. DAVIS Re: Consolidation several... 07-30-2015, 07:32 AM
Gti182 Re: Consolidation several... 07-30-2015, 07:43 AM
JOHN H. DAVIS Re: Consolidation several... 07-30-2015, 07:56 AM
Gti182 Re: Consolidation several... 07-30-2015, 08:13 AM
kadeo Re: Consolidation several... 07-30-2015, 08:18 AM
JOHN H. DAVIS Re: Consolidation several... 07-30-2015, 08:16 AM
  1. #1
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    469

    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.


    Sub Consolidate()
          
    Set CONS = Sheets("Consolidation")
    Set DEN = Sheets("Denmark")
    Set SPA = Sheets("Spain")
                
    
    'Denmark
    LR = DEN.Range("B" & Rows.Count).End(xlUp).Row
    DEN.Range("B9:CQ" & LR).AutoFilter Field:=94, Criteria1:="Data"
    
    LR = DEN.Range("B" & Rows.Count).End(xlUp).Row
    DEN.Range("B10:CQ" & LR).Copy
    CONS.Range("A2").PasteSpecial xlPasteValues
    
    'Spain
    LR = SPA.Range("B" & Rows.Count).End(xlUp).Row
    SPA.Range("B9:CQ" & LR).AutoFilter Field:=94, Criteria1:="Data"
    
    LR = SPA.Range("B" & Rows.Count).End(xlUp).Row
    SPA.Range("B10:CQ" & LR).Copy
    LR = CONS.Range("B" & Rows.Count).End(xlUp).Row
    CONS.Range("A" & LR + 1).PasteSpecial xlPasteValues
         
    End Sub
    Last edited by Gti182; 07-30-2015 at 08:13 AM.

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. 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