Trying to copy rows from one sheet (from row 8) to another sheet (from row 4) in same workbook. The code copies but overwrites every row and I'm left with one row. Can anyone spot what I've done wrong please? See code below
Note: This piece of code is part of a larger project. I posted a thread yesterday in this site only where I listed everything I want to do in this project. The thread is titled Help with VBA Macros to automate repetitive tasks and produce reports
Note: This piece of code is part of a larger project. I posted a thread yesterday in this site only where I listed everything I want to do in this project. The thread is titled Help with VBA Macros to automate repetitive tasks and produce reports
Code:
Sub CopyToPAFStatusClient()
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
' Change worksheet designations as needed
Set Source = ActiveWorkbook.Worksheets("PM-PA Assignment of Personnel")
Set Target = ActiveWorkbook.Worksheets("Test Page")
Sheets("Test Page").Range("A4:AZ2000").ClearContents
lastrow = Target.Range("F65000").End(xlUp).Row + 1
j = lastrow ' Start copying to row 4 in target sheet
For Each c In Source.Range("F8:F2000") ' Do 2000 rows
If c = "1" Then
Source.Rows(c.Row).Copy Target.Rows(j).End(xlUp).Offset(1)
j = lastrow + 1
End If
Next c
End Sub