Hello,
I have ben using this code to combine all the sheets in one workbook into one sheet then delete the all but the combined one. It has been working fine but I just found out that if there is just a header row it copies the header row into the combined sheet. I don't want any header rows brought into the combined sheet, it does not doit on any of the sheets with data in rows 2 and beyond only the blank sheets.
Can anyone see how to modify this code to not take the header row or ignore the sheets that don't have data in row 2 and beyond?
I have ben using this code to combine all the sheets in one workbook into one sheet then delete the all but the combined one. It has been working fine but I just found out that if there is just a header row it copies the header row into the combined sheet. I don't want any header rows brought into the combined sheet, it does not doit on any of the sheets with data in rows 2 and beyond only the blank sheets.
Can anyone see how to modify this code to not take the header row or ignore the sheets that don't have data in row 2 and beyond?
Code:
Sub CombineTabsInventoryReports()
'this macro will combine all sheets within a WB into one sheet
'Make sure that all header rows on all tabs are identical.
Dim J As Integer
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Combined"
Sheets(2).Activate
Range("A1").EntireRow.Select
Selection.Copy Destination:=Sheets(1).Range("A1")
For J = 2 To Sheets.Count
Sheets(J).Activate
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
Selection.Copy Destination:=Sheets(1).Range("A65536").End(xlUp)(2)
Next
'This section will delete all tabs but the combined one
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In Application.ActiveWorkbook.Worksheets
If xWs.Name <> "Combined" Then
xWs.Delete
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub