OK so I have a code where if there is a S in a column it will delete the row of the S and move the row over to another sheet, then if there is a D in the column it will simply delete the row indicated, but once I inserted the D part I am getting an error where if I put an S in the column I then get a run time error after it completes the if then. I also get the same error when I insert a line.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False_
If Target.Column = 15 And Target.Value = "S" Then
'targets column O and if there is an S then
Rows(Target.Row).Copy _
Destination:=Worksheets("Shipped").Rows(Worksheets("Shipped") _
.UsedRange.SpecialCells(xlCellTypeLastCell).Row + 1)
Rows(Target.Row).Delete shift:=xlUp
End If
'Copy the row with the S paste it in one above the last used cell. Then delete said row and shift data up
If Target.Column = 15 And Target.Value = "D" Then
'targets column O and if there is an S then
Rows(Target.Row).Delete shift:=xlUp
End If
Application.EnableEvents = True
End Sub
the row that highlights when I debug it is the "If Target.Column = 15 And Target.Value = "D" Then" when it goes through the S script, but it highlights the S line when I insert a line.
Any help is much apriciated
-Sieg
EDIT: The runtime error is 424 if that helps
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False_
If Target.Column = 15 And Target.Value = "S" Then
'targets column O and if there is an S then
Rows(Target.Row).Copy _
Destination:=Worksheets("Shipped").Rows(Worksheets("Shipped") _
.UsedRange.SpecialCells(xlCellTypeLastCell).Row + 1)
Rows(Target.Row).Delete shift:=xlUp
End If
'Copy the row with the S paste it in one above the last used cell. Then delete said row and shift data up
If Target.Column = 15 And Target.Value = "D" Then
'targets column O and if there is an S then
Rows(Target.Row).Delete shift:=xlUp
End If
Application.EnableEvents = True
End Sub
the row that highlights when I debug it is the "If Target.Column = 15 And Target.Value = "D" Then" when it goes through the S script, but it highlights the S line when I insert a line.
Any help is much apriciated
-Sieg
EDIT: The runtime error is 424 if that helps
Last edited: