Hi everyone,
I got a VB code from this site to move rows to different sheet based on cell value. It worked amazing for once, but if I run it twice, rows in target sheet are getting replaced with new ones or getting deleted.
Can you help me on making the code to look for next empty row?
Thank you so much in advance for helping me. I'm new to this forum and the code that I got was an amazing except that small issue that I couldn't fix.
Sub CopyYes()
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
Application.ScreenUpdating = False
' Change worksheet designations as needed
Set Source = ActiveWorkbook.Worksheets("Facilities Requests")
Set Target = ActiveWorkbook.Worksheets("Completed Projects")
Application.ScreenUpdating = False
Target.Select
With Target
.Rows("2:1000").Select
Selection.Delete Shift:=xlUp
End With
Source.Select
j = 2 ' Start copying to row 1 in target sheet
For Each c In Source.Range("L2:L1000") ' Do 1000 rows
If c.Value = "Completed" Then
Source.Rows(c.Row).Copy Target.Rows(j)
Source.Rows(c.Row).Delete
j = j + 1
End If
Next c
Target.Select
Target.Range("A1").Select
Worksheets(1).Calculate
'Application.CutCopyMode = False
Source.Select
Source.Range("C5").Select
Application.ScreenUpdating = True
End Sub
Bookmarks