moving a row to another sheet based on category of the row

Copper Contributor

I manage to send a row from one sheet to another sheet but I need help in moving a row to another sheet based on the row category

i don't know if this clear enough but please let me know if it isn't.

 

Sub MoveBasedonValue()

 

Dim xRg As Range

Dim xCell As Range

Dim A As Long

Dim B As Long

Dim C As Long

 

A = Worksheets("master").UsedRange.Rows.Count

B = Worksheets("completed").UsedRange.Rows.Count

 

If B = 1 Then

    If Application.WorksheetFunction.CountA(Worksheets("completed").UsedRange) = 0 Then B = 0

End If

Set xRg = Worksheets("master").Range("D1:D" & A)

On Error Resume Next

Application.ScreenUpdating = False

For C = 1 To xRg.Count

    If CStr(xRg(C).Value) = "Done" Then

        xRg(C).EntireRow.Copy Destination:=Worksheets("completed").Range("A" & B + 1)

        xRg(C).EntireRow.Delete

        If CStr(xRg(C).Value) = "Done" Then

            C = C - 1

        End If

        B = B + 1

    End If

Next

Application.ScreenUpdating = True

End Sub

0 Replies