Hey Mike I've changed some more things and for some reason it's looping through all of the worksheets twice and adding them to DATA twice. Can you tell me why it's doing that? Here's the code so far:
Option Explicit
Sub ConsolidateMyData()
'===================================================================
'Declare Variables
'===================================================================
Dim DataLastRow As Integer 'Used to find the last row used on the DATA tab
Dim MonthLastRow As Integer 'Used to find the last row used on the month tabs
Dim TotalsTab As String 'Used to define which tab to return to at the end
Dim ws As Worksheet ' Used to loop through the worksheets
'===================================================================
'Define Variables
'===================================================================
TotalsTab = ThisWorkbook.Sheets("Totals").Name 'Defines the tab name
DataLastRow = ThisWorkbook.Worksheets("Data").Cells(Rows.Count, 1).End(xlUp).Row + 1 ' Finds the FIRST unused row on the DATA tab
'===================================================================
'Setup For Speed
'===================================================================
Application.ScreenUpdating = False 'turns off Screen Updating
Application.Calculation = xlCalculationManual 'turns off Calculations
'===================================================================
'Clear Data tab before begining
'===================================================================
ThisWorkbook.Sheets("Data").Activate
Range("A2:I1048576").Clear 'Simply clears the Data tab except for the headers
'===================================================================
'This isnt Necessary, only to use the statusbar to indicate how far along you are
'===================================================================
For Each ws In Worksheets
Application.StatusBar = "Aggregating worksheet: " & ws.Name ' just making the
ws.Activate
If Len(Range("A1").Value) > 1 And ws.Name <> "Data" Then 'this is all to detemine if the the tab houses data , we can change it if need be
DataLastRow = ThisWorkbook.Worksheets("Data").Cells(Rows.Count, 1).End(xlUp).Row + 1 'used to find first empty row on data tab
MonthLastRow = ThisWorkbook.Worksheets(ws.Name).Cells(Rows.Count, 1).End(xlUp).Row ' used to find last row on month tab
ThisWorkbook.Worksheets(ws.Name).Range("A2:I" & MonthLastRow).Copy ThisWorkbook.Worksheets("Data").Range("A" & DataLastRow) 'copies all of month tab to bottom of DATA tab
End If
Next ws
'===================================================================
'End Macro Procedures
'===================================================================
ThisWorkbook.Sheets(TotalsTab).Activate 'Returns to the TotalsTab
Application.StatusBar = False 'Clears the Statusbar
Application.ScreenUpdating = True 'turns screen updating back on
Application.Calculation = xlCalculationAutomatic ' turns calculations back on
ThisWorkbook.RefreshAll 'Refreshes all pivot tables
MsgBox "Complete" 'offers a message box
End Sub
Bookmarks