I have the below code copying data from multiple worksheets on to a master worksheet without the header row. It works fine if data is entered however if no data is entered on a sheet it copies the header row. How can I change it so that the header row is always ignored even if it is the only row of data on a sheet?
OptionExplicit
SubCollate_Sheets()
Dim ws As Worksheet, sh As Worksheet
Set sh = Sheets("Triage")
Dim lr As Long, lrw As Long, lc As Long
Application.ScreenUpdating= False
ForEach ws In Worksheets
If ws.Name <> "Triage" And ws.Name <> "Lists"Then
lrw = ws.Range("A" &Rows.Count).End(xlUp).Row
lc = ws.Cells(1, Columns.Count).End(xlToLeft).Column
lr = sh.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range(ws.Cells(2, 1), ws.Cells(lrw, lc)).Copy
sh.Range("A" & lr).PasteSpecial xlPasteValues
ws.Range(ws.Cells(2, 1), ws.Cells(lrw, lc)).EntireRow.Delete
End If
Next ws
Application.CutCopyMode= False
Application.ScreenUpdating= True
MsgBox" Completed ! "
End Sub
OptionExplicit
SubCollate_Sheets()
Dim ws As Worksheet, sh As Worksheet
Set sh = Sheets("Triage")
Dim lr As Long, lrw As Long, lc As Long
Application.ScreenUpdating= False
ForEach ws In Worksheets
If ws.Name <> "Triage" And ws.Name <> "Lists"Then
lrw = ws.Range("A" &Rows.Count).End(xlUp).Row
lc = ws.Cells(1, Columns.Count).End(xlToLeft).Column
lr = sh.Range("A" & Rows.Count).End(xlUp).Row + 1
ws.Range(ws.Cells(2, 1), ws.Cells(lrw, lc)).Copy
sh.Range("A" & lr).PasteSpecial xlPasteValues
ws.Range(ws.Cells(2, 1), ws.Cells(lrw, lc)).EntireRow.Delete
End If
Next ws
Application.CutCopyMode= False
Application.ScreenUpdating= True
MsgBox" Completed ! "
End Sub