I have a small macro that is supposed to copy/paste data from sheet 1 in Book1 to a fresh workbook (Book2). After that, I want it to loop through the rest of the worksheets from Book1 and copy/paste into Book2 but without the headers.
The macro below completes the first step but then continues to copy/pastes the records in sheet 1 every time instead of switching worksheets to copy/paste new data.
Sub CopyData()
' Copy A:D from all sheets to template
Dim ws As Worksheet
Dim sheetIndex As Integer
sheetIndex = 1
'First Sheet pulls in headers and data
Windows("Book1.xlsx").Activate
Sheets(1).Select
Range("A1:D" & Cells(Rows.Count, "C").End(xlUp).Row).Copy
Windows("Book2.xlsm").Activate
ActiveSheet.Paste
Windows("Book1.xlsx").Activate
'Every other worksheet only copies over data
For Each ws In ActiveWorkbook.Worksheets
If ws.Index <> 1 Then
Windows("Book1.xlsx").Activate
Range("A2:D" & Cells(Rows.Count, "C").End(xlUp).Row).Copy
Windows("Book2.xlsm").Activate
Range("A1").End(xlDown).Offset(1).Select
ActiveSheet.Paste
End If
sheetIndex = sheetIndex + 1
Next ws
End Sub
I'm not too experienced so I apologize if the code above isn't optimized. Thanks in advance for your help!