I have the below code which takes rows of data from one worksheet(DataSheet) that has "Actioned" in Column C and should paste it to the next available row on the worksheet (Actioned). The issue at hand is that it doesn't paste it on the next available row, its pasting to Row 2700.
I've cleared contents on all the cells and restarted the workbook but it still doesn't paste it onto the next free row.
can anyone see where I'm going wrong?
Dim xRg As Range
Dim xCell As Range
Dim i As Long
Dim J As Long
Dim K As Long
i = Worksheets("DataSheet").UsedRange.Rows.Count
J = Worksheets("Actioned").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Actioned").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("DataSheet").Range("C2:C" & i)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "Actioned" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Actioned").Range("A" & J + 1)
xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "Actioned" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub ```
I am still a novice at VBA so please bare with my ignorance.