Hi everyone,
I have this VBA code that I found and it works but only if the cell is filled in with "Done". However I would like to have it move the row of cells when there is a returned date put in. The other thing is also that the dates will always be different. So is there a way to move it with the cell just having anything in it? Also is there a way to have this be done automatically once data is in the column G location?
Sub Cheezy()
'Updated by Kutools for Excel 2017/8/28
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("Current borrows").UsedRange.Rows.Count
J = Worksheets("Completed borrows").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Completed borrows").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("Current borrows").Range("G1:G" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "Done" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Completed borrows").Range("A" & J + 1)
xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "Done" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub
Bookmarks