Hi,
I have what seems a fairly simple question that I cannot find a clear answer too on the forum.
I have a log of driver movements, A7:A1000 hold the individual driver ID's as they enter the depot. B7:J1000 holds various records about the drivers movements including importantly a time stamp of when the driver arrived (ie when his ID was entered into the next blank cell in Column A).
Currently the arrival Time Stamp entry is triggered by a sub looking for a "SelectionChange" within column A and all this works fine ................. except when we get the drivers ID wrong and we need to correct it later.
What it does now is create a new (wrong from the drivers perspective!) Time Stamp for arrival because it detects the Change and updates the time stamp.
Is there a way to NOT see a change of Driver ID as a new event and leave the time stamp as was (ie only trigger the Time Stamp Sub if a Column A blank cell has data entered into it)?
CODE BELOW:
Private Sub Worksheet_Change1(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("A7:A1000"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
'.Offset(0, 5).ClearContents
.Offset(0, 6).ClearContents
Else
With .Offset(0, 6)
.NumberFormat = "hh:mm:ss"
.Value = time
End With
End If
Application.EnableEvents = True
End If
End With
End Sub
Thanks,
Mike
I have what seems a fairly simple question that I cannot find a clear answer too on the forum.
I have a log of driver movements, A7:A1000 hold the individual driver ID's as they enter the depot. B7:J1000 holds various records about the drivers movements including importantly a time stamp of when the driver arrived (ie when his ID was entered into the next blank cell in Column A).
Currently the arrival Time Stamp entry is triggered by a sub looking for a "SelectionChange" within column A and all this works fine ................. except when we get the drivers ID wrong and we need to correct it later.
What it does now is create a new (wrong from the drivers perspective!) Time Stamp for arrival because it detects the Change and updates the time stamp.
Is there a way to NOT see a change of Driver ID as a new event and leave the time stamp as was (ie only trigger the Time Stamp Sub if a Column A blank cell has data entered into it)?
CODE BELOW:
Private Sub Worksheet_Change1(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("A7:A1000"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
'.Offset(0, 5).ClearContents
.Offset(0, 6).ClearContents
Else
With .Offset(0, 6)
.NumberFormat = "hh:mm:ss"
.Value = time
End With
End If
Application.EnableEvents = True
End If
End With
End Sub
Thanks,
Mike