Hey Team,
I was just wondering if the was a way to use VBA to accomplish this task I am trying to finish.
So I have a break tracker right? This break tracker is used for employees at my site. When they scan out for break it records the time they scanned out. Then when they get back from break they and scan back in on a different sheet it tells them where they are going to be for the rest of their shift...What I am wondering is this:
Can I get the scan to also:
1) Find the user id from the previous scan and
2) Insert the time the 2nd scan happened.
So:
User Scans out (Records Time) -> User Scans in (Records Time)
This is what I have for the Timestamp stuff so far.
I was just wondering if the was a way to use VBA to accomplish this task I am trying to finish.
So I have a break tracker right? This break tracker is used for employees at my site. When they scan out for break it records the time they scanned out. Then when they get back from break they and scan back in on a different sheet it tells them where they are going to be for the rest of their shift...What I am wondering is this:
Can I get the scan to also:
1) Find the user id from the previous scan and
2) Insert the time the 2nd scan happened.
So:
User Scans out (Records Time) -> User Scans in (Records Time)
This is what I have for the Timestamp stuff so far.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Timestamp Data
Dim myTableRange As Range
Dim myDateTimeRange As Range
Dim myUpdatedRange As Range
'Your data table range
Set myTableRange = Range("A2:B500")
'Check if the changed cell is in the data table or not.
If Intersect(Target, myTableRange) Is Nothing Then Exit Sub
'Stop events from running
Application.EnableEvents = False
'Column for the date/time
Set myDateTimeRange = Range("C" & Target.Row)
'Column for last updated date/time
Set myUpdatedRange = Range("D" & Target.Row)
'Determine if the input date/time should change
If myDateTimeRange.Value = "" Then
myDateTimeRange.Value = Now
End If
'Update the updated date/time value
'myUpdatedRange.Value = Now
'Turn events back on
Application.EnableEvents = True
End Sub