You put the issue code (green) after "Exit Sub" (red) statement, of course, they will never be executed.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
Application.EnableEvents = False
If Not Intersect(Target, Range("F4")) Is Nothing Then
If Not IsNumeric(Range("F4").Value) Then
MsgBox "Numbers only NO TEXT ALLOWED" & vbCrLf & "" & vbCrLf & "Only one Part Number per Request"
Application.Undo
Sheets("Sheet1").Select
Range("F4").Select
Range("F4:J4").Cells.ClearContents
GoTo Continue
End If
End If
Continue:
Application.EnableEvents = True
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume Continue
'
'
'Code in question ????????????????????????????????????????????????????????????????????
'
Sheets("Sheet1").Select
If Target.Address = "$F$7" And Target.Value > 3 Then
MsgBox "Numbers may not exceed 3"
Application.Goto Reference:=Range("F8"), Scroll:=False
End If
'??????????????????????????????????????????????????????????????????????????????????????????
' Code refers to Sheet1 Cell F7 which is the difference between the (date requested and the date needed).
'
'
End Sub
Your code should be something like this :
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler
Application.EnableEvents = False
If Not Intersect(Target, Range("F4")) Is Nothing Then
If Not IsNumeric(Range("F4").Value) Then
MsgBox "Numbers only NO TEXT ALLOWED" & vbCrLf & "" & vbCrLf & "Only one Part Number per Request"
Application.Undo
Range("F4").Select
Range("F4:J4").Cells.ClearContents
GoTo Continue
End If
End If
If Target.Address = "$F$7" And Target.Value > 3 Then
MsgBox "Numbers may not exceed 3"
Application.Goto Reference:=Range("F8"), Scroll:=False
End If
Continue:
Application.EnableEvents = True
Exit Sub
ErrorHandler:
MsgBox Err.Description
Resume Continue
End Sub
Bookmarks