Any idea why i am getting a run time error with the code shown below. I f i hit debug the colum "If Target.column = 21 Then" is highlighted. Basically I am just trying to delete a row if Yes is in column 24 and if yes is in column 21 then i want the row moved to another spreadsheet. Everything works and the code does what i want, i just get this pesky run time error that pops up anyway. Thanks very much!
***********************************************************************************************************************************
Code
If Target.Column = 24 Then
If Target = "Yes" Then
YesNo = MsgBox("Do you want to delete the entire contents of this row?", vbYesNo + vbCritical, "Caution")
Select Case YesNo
Case vbYes
For Each r In Target
If UCase(r.Value) = "YES" Then
Application.EnableEvents = False
Sheet1.Unprotect ("gf")
Sheet6.Unprotect ("gf")
Target.EntireRow.Delete
End If
Next r
Application.EnableEvents = True
Sheet1.Protect ("gf"), AllowFiltering:=True, AllowFormattingColumns:=True, AllowDeletingRows:=True
Sheet6.Protect ("gf"), AllowFiltering:=True, AllowFormattingColumns:=True, AllowDeletingRows:=True
Case vbNo
If Target = "Yes" Then
Target.ClearContents
End If
End Select
End If
End If
If Target.Column = 21 Then
If Target = "Yes" Then
YesNo = MsgBox("Do you want to move this transaction to the Error Log?", vbYesNo + vbCritical, "Caution")
Select Case YesNo
Case vbYes
For Each r In Target
If UCase(r.Value) = "YES" Then
Application.EnableEvents = False
Sheet1.Unprotect ("gf")
Sheet6.Unprotect ("gf")
nxtRow = Sheets("Error Log").Range("A" & Rows.Count).End(xlUp).Row + 1
Target.EntireRow.Copy Destination:=Sheets("Error Log").Range("A" & nxtRow)
Target.EntireRow.Delete
End If
Next r
Application.EnableEvents = True
Sheet1.Protect ("gf"), AllowFiltering:=True, AllowFormattingColumns:=True, AllowDeletingRows:=True
Sheet6.Protect ("gf"), AllowFiltering:=True, AllowFormattingColumns:=True, AllowDeletingRows:=True
Case vbNo
If Target = "Yes" Then
Target.ClearContents
End If
End Select
End If
End If
End Sub
Display More