I have the following code to move a row from one table to another table in the same workbook when specific text is entered in to column J. This is working fine, except it does not extend the table in the destination sheet, just adds it to the end and the existing formulas do not auto populate in the destination table. I understand this may have something to do with pasting an entire row. How do I reword this to be able to extend the table in the destination sheet?
Thanks.
Rich (BB code):
Sub MoveBasedOnValue()
'Created by Excel 10 Tutorial
Dim xRg As Range
Dim xCell As Range
Dim A As Long
Dim B As Long
Dim C As Long
A = Worksheets("PENDING").UsedRange.Rows.Count
B = Worksheets("INVOICE").UsedRange.Rows.Count
If B = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("INVOICE").UsedRange) = 0 Then B = 0
End If
Set xRg = Worksheets("PENDING").Range("J1:J" & A)
On Error Resume Next
Application.ScreenUpdating = False
For C = 1 To xRg.Count
If CStr(xRg(C).Value) = "Completed" Then
xRg(C).EntireRow.Copy Destination:=Worksheets("INVOICE").Range("A" & B + 1)
xRg(C).EntireRow.Delete
If CStr(xRg(C).Value) = "Completed" Then
C = C - 1
End If
B = B + 1
End If
Next
Thanks.
Last edited by a moderator: