Two macros in one worksheet
Hi all,
I'm having some issue with adding extra layers of complexity to a macro code.
Orginally,
I have been using a macro to move and delete 'completed tasks' from a Open tab to a Closed tab. The macro is here:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 12 Then
If Target = "Yes" Then
Application.EnableEvents = False
nxtRow = Sheets("Closed Issues").Range("L" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Closed Issues").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
End If
Application.EnableEvents = True
End Sub
However, I want to develop it further and repeat this macro, adding a new function to move to a different sheet depending on cell value. Like this:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 12 Then
If Target = "Yes" Then
Application.EnableEvents = False
nxtRow = Sheets("Closed Issues").Range("L" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Closed Issues").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
End If
If Target.Column = 13 Then
If Target = "Low" Then
Application.EnableEvents = False
nxtRow = Sheets("Low Priority Issues").Range("M" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Low Priority Issues").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
End If
Application.EnableEvents = True
End Sub
When I do this repeat, it comes up with an error saying "Object required", the both set of macros stop working and I'm unsure how I can get both of this functions working together.
Any advice/help would be super appreciated.
Thanks,
|