Working on a worksheet that timestamps a localized time based on a user input in column A. It works fine if the input is entered and "enter" or "down arrow" is used to move to the next cell or the cell below. If "TAB" or "right arrow" is used to go to the next cell right it updates the date and time in the row above the current row. Here is the code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rWatchRange As Range
On Error GoTo ResetEvents
'Set range variable to A1:A1000
Set rWatchRange = Range("A1:A1000")
Dim Test As Double
Test = LocalOffsetFromGMT()
Dim first As Integer 'holds number of the first row selected
Dim last As Integer 'holds number of the last row selected
'assignments to first and last based on user cell selection
first = Selection.Cells(1, 1).Row
last = Selection.Cells(0, Selection.Columns.Count).Row
'The cell they have changed (Target) _
is within A1:A1000
Select Case Target.Value
Case "IP"
'sets the Actual Start datetime value in columns E and F
ActiveSheet.Range("E" & last) = Format((Now() + GetCentralOffset / 24), "M/dd/yyyy hh:mm:ss AM/PM")
ActiveSheet.Range("F" & last) = Format((Now() + GetCentralOffset / 24), "M/dd/yyyy hh:mm:ss AM/PM")
Case "ip"
'sets the Actual Start datetime value in columns E and F
ActiveSheet.Range("E" & last) = Format((Now() + GetCentralOffset / 24), "M/dd/yyyy hh:mm:ss AM/PM")
ActiveSheet.Range("F" & last) = Format((Now() + GetCentralOffset / 24), "M/dd/yyyy hh:mm:ss AM/PM")
Case "NS"
'clears Actual Start/End datetime values in columns E, F, G, H
ActiveSheet.Range("E" & last) = ""
ActiveSheet.Range("F" & last) = ""
ActiveSheet.Range("G" & last) = ""
ActiveSheet.Range("H" & last) = ""
Case "ns"
'clears Actual Start/End datetime values in columns E, F, G, H
ActiveSheet.Range("E" & last) = ""
ActiveSheet.Range("F" & last) = ""
ActiveSheet.Range("G" & last) = ""
ActiveSheet.Range("H" & last) = ""
End Select
ResetEvents:
Application.EnableEvents = True
End Sub
Any thoughts on why it is updating the row above when TAB and right arrow are used and how to get it to update the correct row?