I have a main sheet titled Task List with a list of rows, and I need each row to be copied to a specific sheet based on the contents of cells in Column I. There are four other sheets (titled Admin, Engine, Lab, and RD) where these values need to be copied to, depending on the value in Column I. Additionally, there is a separate sheet named Completed that where rows should move to (not copy) which contain the word "Complete" in Column E of the sheet titled Task List.
Below is the code that I have currently that I sourced from a post I found. It's not currently copying anything when I run it. Can anyone suggest new code or modifications to this?
Sub copyRows()
Set a = Sheets("Task List")
Set b = Sheets("Admin")
Set c = Sheets("Engine")
Set d = Sheets("Lab")
Set e = Sheets("RD")
Set f = Sheets("Completed")
Dim t
Dim u
Dim v
Dim w
Dim y As Long
Dim z
t = 2
u = 2
v = 2
w = 2
z = 3
Do Until IsEmpty(a.Range("I" & z))
If a.Range("I" & z) = "Admin" Then
t = t + 1
b.Rows(t).Value = a.Rows(z).Value
End If
If a.Range("I" & z) = "Engine" Then
u = u + 1
c.Rows(u).Value = a.Rows(z).Value
End If
If a.Range("I" & z) = "Lab" Then
v = v + 1
d.Rows(v).Value = a.Rows(z).Value
End If
If a.Range("I" & z) = "RD" Then
w = w + 1
e.Rows(w).Value = a.Rows(z).Value
End If
If a.Range("E" & z) = "COMPLETE" Then
y = f.Range("a" & Rows.Count).End(xlUp).Row + 1
f.Rows(y).Value = a.Rows(z).Value
a.Rows(z).Delete
z = z - 1
End If
z = z + 1
Loop
End Sub