CalumJames
New Member
- Joined
- Jun 18, 2011
- Messages
- 13
Ok, so I've created the below VBA to move rows however it seems to work some of the time, but then others it throws a runtime 424 error.
Does anyone have any idea why?
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 11 Then
If Target = "Completed Minors" Then
Application.EnableEvents = False
nxtRow = Sheets("Completed Minors").Range("K" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Completed Minors").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
If Target = "Completed Majors" Then
Application.EnableEvents = False
nxtRow = Sheets("Completed Majors").Range("K" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Completed Majors").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
If Target = "Completed Other Sites" Then
Application.EnableEvents = False
nxtRow = Sheets("Completed Other Sites").Range("K" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Completed Other Sites").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
If Target = "Minor Transitions" Then
Application.EnableEvents = False
nxtRow = Sheets("Minor Transitions").Range("K" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Minor Transitions").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
End If
Application.EnableEvents = True
End Sub
Does anyone have any idea why?
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 11 Then
If Target = "Completed Minors" Then
Application.EnableEvents = False
nxtRow = Sheets("Completed Minors").Range("K" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Completed Minors").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
If Target = "Completed Majors" Then
Application.EnableEvents = False
nxtRow = Sheets("Completed Majors").Range("K" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Completed Majors").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
If Target = "Completed Other Sites" Then
Application.EnableEvents = False
nxtRow = Sheets("Completed Other Sites").Range("K" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Completed Other Sites").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
If Target = "Minor Transitions" Then
Application.EnableEvents = False
nxtRow = Sheets("Minor Transitions").Range("K" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy _
Destination:=Sheets("Minor Transitions").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
End If
Application.EnableEvents = True
End Sub