MaxxLevell
New Member
- Joined
- Nov 19, 2020
- Messages
- 16
- Office Version
- 365
- Platform
- Windows
I have the following code that is generating a Run-Time Error '424' Object Required message. The code is actually performing the way I want it to...but with the error every time I enter 'N' in the target column. If 'Y' is entered, it does not present the error. When I select debug, it's highlighting the code that has the blue text. I'm brand new to vba, and the original code was found on this site and modified to correspond with my project.
Thank you for any assistance!
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 11/18/2020 4:18:03 AM CDT
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 19 Then
Dim Lastrow As Long
Dim Lastrow2 As Long
Lastrow = Sheets("ICS Not Needed").Cells(Rows.Count, 1).End(xlUp).Row + 1
Lastrow2 = Sheets("ICS Completed").Cells(Rows.Count, 1).End(xlUp).Row + 1
Dim ans As Long
ans = Target.Row
If Target.Value = "N" Then
Rows(ans).Copy Sheets("ICS Not Needed").Rows(Lastrow)
Rows(ans).Delete
End If
If Target.Value = "Y" Then
Rows(ans).Copy Sheets("ICS Completed").Rows(Lastrow2)
Rows(ans).Delete
End If
End If
End Sub
Thank you for any assistance!