The following code is supposed to alert the user if the number they have entered is non-sequential.
When run though, at the Set oldVal line, it errors and I can't figure out what is wrong.
Any help will be appreciated.
Regards.
When run though, at the Set oldVal line, it errors and I can't figure out what is wrong.
Code:
Sub Worksheet_Change(ByVal Target As Range)
Dim oldVal As Range, newVal As Range
Set Target = Range("A" & Rows.Count).End(xlUp)
With Target
If Target.Value > 1 Then
Set oldVal = Target.Offset(-1, 0).Value
Set newVal = Target.Value
If newVal <> oldVal + 1 Then
MsgBox "This is not a sequential number", , "Invalid Number?"
End If
'End If
End With
End Sub
Regards.