Hopefully my title hasn't been too confusing.
I have inserted VBA code into a worksheet to record when transactions were entered and by whom. One of the processes that run over month end determines where the transactions are to end up, and moves certain transactions by copying them to the new output and deleting the original. I have found that the deletion results in the next transaction to be erroneously stamped with the current date time and user.
Is there a solution? or a way to prevent the code from running when rows are being deleted?
this is the code I have in the worksheet:-
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myTableRange As Range
Dim myDateRange As Range
Dim myTimeRange As Range
Dim myUser As Range
'code to automatically stamp trans with date, time & user
Set myTableRange = Range("B2:I10000")
If Intersect(Target, myTableRange) Is Nothing Then Exit Sub
Set myDateRange = Range("BL" & Target.Row)
Set myTimeRange = Range("BM" & Target.Row)
Set myUser = Range("BN" & Target.Row)
myDateRange.Value = DateValue(Now)
myTimeRange.Value = TimeValue(Now)
myUser.Value = Application.UserName
End Sub
I have inserted VBA code into a worksheet to record when transactions were entered and by whom. One of the processes that run over month end determines where the transactions are to end up, and moves certain transactions by copying them to the new output and deleting the original. I have found that the deletion results in the next transaction to be erroneously stamped with the current date time and user.
Is there a solution? or a way to prevent the code from running when rows are being deleted?
this is the code I have in the worksheet:-
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myTableRange As Range
Dim myDateRange As Range
Dim myTimeRange As Range
Dim myUser As Range
'code to automatically stamp trans with date, time & user
Set myTableRange = Range("B2:I10000")
If Intersect(Target, myTableRange) Is Nothing Then Exit Sub
Set myDateRange = Range("BL" & Target.Row)
Set myTimeRange = Range("BM" & Target.Row)
Set myUser = Range("BN" & Target.Row)
myDateRange.Value = DateValue(Now)
myTimeRange.Value = TimeValue(Now)
myUser.Value = Application.UserName
End Sub