Hi, I am trying to create a summary worksheet with data from 26 separate tabs.
I want to exclude the header in the 26 data sheets and copy from sheet1 to summary sheet, from sheet2 to summary sheet etc without the header.
Sub CopySummary()
Dim arr As Variant
Dim ws As Worksheet
Set ws = Sheets("Summary")
If ws Is Nothing Then
Exit Sub
End If
Dim LastRow As Long, LastRow2 As Long, LastRow3 As Long, LastRow4 As Long
Dim sht As Worksheet, sht2 As Worksheet, sht3 As Worksheet
Set sht = Sheets("Town1")
Set sht2 = Sheets("Summary")
Set sht3 = Sheets("Town2")
LastRow = sht.Cells(sht.Rows.Count, "B").End(xlUp).Row
LastRow2 = sht2.Cells(sht2.Rows.Count, "B").End(xlUp).Row
LastRow3 = sht3.Cells(sht3.Rows.Count, "B").End(xlUp).Row
Sheets("Town1").Range("A2:V" & LastRow).Copy Destination:=Sheets("Summary").Range("A2:V" & LastRow2)
LastRow4 = sht2.Cells(sht2.Rows.Count, "A").End(xlUp).Row
Sheets("Town2").Range("A2:V" & LastRow3).Copy Destination:=Sheets("Summary").Range("A" & LastRow4 & ":V" & LastRow4)
End Sub
All suggestions are welcome.
1. Store the 26 sheet names in an array
2. Loop through the array and copy items from sheet1 to summary sheet, sheet2 to summary etc
3. Apply advanced filter on the summary
Bookmarks