Forum Discussion
How do I move data completely from one sheet to another once it meets a certain criteria?
A little late but I figured WHY NOT..............
Just Replace the Purple highlighted sections below with the keywords you want.
(Replace Sheet 1 with your 1st sheets name, Replace Sheet 2 with your 2nd sheets name. The word "Completed" is the trigger word that is checked against-Could also be "DONE" or "CLOSED", and the K2:K section is the Range of where to look for the trigger word. )
I use this macro often.
Sub CheezyBeans()
'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("Sheet1").UsedRange.Rows.Count
J = Worksheets("Sheet2").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Sheet2").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("Sheet1").Range("K2:K" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "Completed" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Sheet2").Range("A" & J + 1)
xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "Completed" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub