Hi Matt,
This code will add a new sheet and paste the data from all other sheets (Note: this assumes that all sheets are in the same format).
Public Sub ImportData()
Dim wksMaster As Excel.Worksheet
Dim wksSheet As Excel.Worksheet
Dim lLastDataRow As Long
Dim lMasterRow As Long
Dim lLastRow As Long
Const lFIRST_DATA_ROW As Long = 3
Set wksMaster = ThisWorkbook.Sheets.Add(, Sheets(ThisWorkbook.Sheets.Count))
wksMaster.Name = "Master " & Format(Now(), "dd.mm.yy hhmm")
' copy the header rows
Sheets(1).Rows("1:2").EntireRow.Copy
wksMaster.Cells(1, 1).PasteSpecial , Paste:=xlAll
lMasterRow = lFIRST_DATA_ROW
For Each wksSheet In ThisWorkbook.Sheets
If wksSheet.Name <> wksMaster.Name Then
' use the last filled cell in column A as the last data row
lLastRow = wksSheet.Cells(wksSheet.Rows.Count, 1).End(xlUp).Row
' copy from the first to last rows
wksSheet.Rows(lFIRST_DATA_ROW & ":" & lLastRow).Copy
wksMaster.Cells(lMasterRow, 1).PasteSpecial , Paste:=xlAll
' set the new destination row on the master sheet
lMasterRow = wksMaster.Cells(wksMaster.Rows.Count, 1).End(xlUp).Row
End If
Next
Set wksMaster = Nothing
Set wksSheet = Nothing
End Sub
Cheers,
Dom
Bookmarks