Hi,
I am running a macro that combines worksheets that are all laid out in the exact same format. Consequently, I only need Row 1 (the headers) from the first worksheet that is copied, I just need from Row 2 on for the other worksheets. This is my current code, which works fine for combining everything, except it includes Row 1 from all worksheets. Will you help me with what code I need to insert where? *ignore the <> "Main" stuff, that worksheet is not being combined, and is completely separate from this task.*
'Combine the sheets
For Each ws In Worksheets
If ws.Name <> "Main" _
And ws.Name <> "Create File" _
And ws.Name <> "Save as DIF" _
And ws.Name <> "Target" Then
'Find last column with data
nLastCol = ws.Cells(5, ws.Columns.Count).End(xlToLeft).Column
'Find last row with data
nLastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
'Define the range and copy
ws.Range(ws.Cells(1, "A"), ws.Cells(nLastRow, nLastCol)).Copy
'PasteSpecial
With wsTarget
nTargetLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
wsTarget.Range("A" & nTargetLastRow + 0).PasteSpecial
End With
End If
Next ws
With Application
.DisplayAlerts = True
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Bookmarks