billandrew
Well-known Member
- Joined
- Mar 9, 2014
- Messages
- 743
Good afternoon
I am trying to copy data from worksheet "Project" column G "Over" to inserted sheet "Over" to row 5 of the new sheet. Code I am using is copying the header row (row 4) and breaking at that point.
Not sure what is going wrong.
Sub Project()
Dim i As Long
Dim lr As Long
Dim lr2 As Long
Dim result As String
Sheets.Add after:=Worksheets("Project")
ActiveSheet.Name = "Over"
Sheets("Project").Activate
lr = Sheets("Project").Cells(Rows.Count, "G").Row
For i = 5 To lr
If Sheets("Project").Cells(i, "G").Value = "Over" Then
result = Cells(i, "G").Value
Sheets("Project").Rows(4).Copy Destination:=Sheets("Over").Rows(4)
lr2 = Sheets(result).Cells(Rows.Count, "G").End(xlUp).Row + 5
Rows(i).Copy desination:=Sheets(result).Rows(lr2)
End If
Next i
End Sub
I am trying to copy data from worksheet "Project" column G "Over" to inserted sheet "Over" to row 5 of the new sheet. Code I am using is copying the header row (row 4) and breaking at that point.
Not sure what is going wrong.
Sub Project()
Dim i As Long
Dim lr As Long
Dim lr2 As Long
Dim result As String
Sheets.Add after:=Worksheets("Project")
ActiveSheet.Name = "Over"
Sheets("Project").Activate
lr = Sheets("Project").Cells(Rows.Count, "G").Row
For i = 5 To lr
If Sheets("Project").Cells(i, "G").Value = "Over" Then
result = Cells(i, "G").Value
Sheets("Project").Rows(4).Copy Destination:=Sheets("Over").Rows(4)
lr2 = Sheets(result).Cells(Rows.Count, "G").End(xlUp).Row + 5
Rows(i).Copy desination:=Sheets(result).Rows(lr2)
End If
Next i
End Sub