Hello Everyone,
As always, any assistance is greatly appreciated! In the workbook, I have to sheets (sheet1 and sheet2) and a button. When clicked, every row in Sheet1 with the cell value “Complete” is deleted and copied to Sheet2. The data is in tables (Table1 and Table2). The problem is when it copies over, it doesn’t remain in a table format, but rather copies the data under the table. What I want is for the data to copy from table to table. I’ve attached the sample workbook. Thank you again!
roro
Sub MoveRow_DeleteOriginal()
Dim rg As Range
Dim xc As Range
Dim p As Long
Dim q As Long
Dim r As Long
p = Worksheets("Sheet1").UsedRange.Rows.Count
q = Worksheets("Sheet2").UsedRange.Rows.Count
If q = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Sheet2").UsedRange) = 0 Then q = 0
End If
Set rg = Worksheets("Sheet1").Range("G1:G" & p)
On Error Resume Next
Application.ScreenUpdating = False
For r = 1 To rg.Count
If CStr(rg(r).Value) = "Complete" Then
rg(r).EntireRow.Copy Destination:=Worksheets("Sheet2").Range("A" & q + 1)
rg(r).EntireRow.Delete
If CStr(rg(r).Value) = "Complete" Then
r = r - 1
End If
q = q + 1
End If
Next
Application.ScreenUpdating = True
End Sub