You are on page 1of 1

Sub CombineSheets()

Dim ws As Worksheet
Dim lastRow As Long
Dim lastCol As Long
Dim destSheet As Worksheet
Dim firstRow As Boolean

Set destSheet =
ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))
destSheet.Name = "Compiled"
firstRow = True

For Each ws In ThisWorkbook.Sheets


If ws.Name <> destSheet.Name Then
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
lastCol = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column
If firstRow Then
ws.Range(ws.Cells(1, 1), ws.Cells(lastRow, lastCol)).Copy
destSheet.Cells(1, 1)
firstRow = False
Else
ws.Range(ws.Cells(2, 1), ws.Cells(lastRow, lastCol)).Copy
destSheet.Cells(destSheet.Cells(destSheet.Rows.Count, 1).End(xlUp).Row + 1, 1)
End If
End If
Next ws
End Sub

You might also like