I am trying to move cells on an excel document from FDJ- TIP to Completed TIP.
I used this in module:
And this in the tab sheet:
It worked on a test sheet and then when applied to the live document it stopped working and wont move the row
I used this in module:
VBA Code:
Sub MoveCompletedRows()
Dim wsSource As Worksheet
Dim wsDestination As Worksheet
Dim lastRow As Long
Dim i As Long
' Set your source and destination sheets
Set wsSource = ThisWorkbook.Sheets("SourceSheet")
Set wsDestination = ThisWorkbook.Sheets("DestinationSheet")
' Find the last row with data in the source sheet
lastRow = wsSource.Cells(wsSource.Rows.Count, "A").End(xlUp).Row
' Loop through each row from the bottom up
For i = lastRow To 1 Step -1
If wsSource.Cells(i, 6).Value = "Completed" Then ' Check if column F (6) is "Completed"
wsSource.Rows(i).Copy Destination:=wsDestination.Rows(wsDestination.Cells(wsDestination.Rows.Count, "A").End(xlUp).Row + 1)
wsSource.Rows(i).Delete
End If
Next i
End Sub
And this in the tab sheet:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("F:F")) Is Nothing Then
Call MoveCompletedRows
End If
End Sub
It worked on a test sheet and then when applied to the live document it stopped working and wont move the row