trickshot829
New Member
Background:
Our technicians produce finished goods.
The time to build the finished goods, along with all of its sub-components, is not being tracked.
I am going to track this via barcode scanning check-in/check-out.
I am going to benchmark the time to put together a finished good (time study) and then analyze data from there.
Each task has a barcode associated.
When technician starts Task 1, they scan associated barcode, "Task 1".
Technicians get interrupted during production so they must check-out.
When technician resumes build they must check back in.
The code below does this:
When "Task 1" is scanned into excel, column A is populated with "Task 1" while column B is populated with the time of scan.
The next time the "Task 1" barcode is scanned, column C is populated with the time of Scan.
This gives the time during the build.
Every time thereafter "Task 1" is scanned, column C is updated with the most recent time.
This creates inaccurate information.
What I need:
Leave the code as is. Except, after the second time "Task X" is entered, start filling in the next columns.
E.g.
A B C D E
Task 1 1am 1:30am 3:30pm 4:00pm
This will show the start and stop time each time the barcode is scanned, rather than just two times. Does that make sense?
Also, if possible, I would like the last cell to have its contents cleared rather than delete the entire row. Here is what I have so far:
Private Sub Worksheet_Change(ByVal Target As Range)
' Code goes in the Worksheet specific module
Dim Rng As Range
Dim strTracking As String
' Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")
Set Rng = Target.Parent.Range("A:A")
' Only look at single cell changes
If Target.Count > 1 Then Exit Sub
' Only look at that range
If Intersect(Target, Rng) Is Nothing Then Exit Sub
' Action if Condition(s) are met
Application.EnableEvents = False
' Look for the Tracking #
strTracking = Columns("A").Find(Target.Value).Address
' If the Tracking # exists, then time stamp the original and delete the Out scan
If strTracking <> Target.Address Then
Range(strTracking).Offset(, 2).Value = Format(Now, "hh:mm:ss AM/PM")
Target.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
Else
' If the Tracking # doesn't exist then enter it and the In time stamp
Target.Offset(0, 1).Value = Format(Now, "hh:mm:ss AM/PM")
End If
Application.EnableEvents = True
End Sub
Our technicians produce finished goods.
The time to build the finished goods, along with all of its sub-components, is not being tracked.
I am going to track this via barcode scanning check-in/check-out.
I am going to benchmark the time to put together a finished good (time study) and then analyze data from there.
Each task has a barcode associated.
When technician starts Task 1, they scan associated barcode, "Task 1".
Technicians get interrupted during production so they must check-out.
When technician resumes build they must check back in.
The code below does this:
When "Task 1" is scanned into excel, column A is populated with "Task 1" while column B is populated with the time of scan.
The next time the "Task 1" barcode is scanned, column C is populated with the time of Scan.
This gives the time during the build.
Every time thereafter "Task 1" is scanned, column C is updated with the most recent time.
This creates inaccurate information.
What I need:
Leave the code as is. Except, after the second time "Task X" is entered, start filling in the next columns.
E.g.
A B C D E
Task 1 1am 1:30am 3:30pm 4:00pm
This will show the start and stop time each time the barcode is scanned, rather than just two times. Does that make sense?
Also, if possible, I would like the last cell to have its contents cleared rather than delete the entire row. Here is what I have so far:
Private Sub Worksheet_Change(ByVal Target As Range)
' Code goes in the Worksheet specific module
Dim Rng As Range
Dim strTracking As String
' Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")
Set Rng = Target.Parent.Range("A:A")
' Only look at single cell changes
If Target.Count > 1 Then Exit Sub
' Only look at that range
If Intersect(Target, Rng) Is Nothing Then Exit Sub
' Action if Condition(s) are met
Application.EnableEvents = False
' Look for the Tracking #
strTracking = Columns("A").Find(Target.Value).Address
' If the Tracking # exists, then time stamp the original and delete the Out scan
If strTracking <> Target.Address Then
Range(strTracking).Offset(, 2).Value = Format(Now, "hh:mm:ss AM/PM")
Target.EntireRow.Delete
ActiveCell.Offset(-1, 0).Select
Else
' If the Tracking # doesn't exist then enter it and the In time stamp
Target.Offset(0, 1).Value = Format(Now, "hh:mm:ss AM/PM")
End If
Application.EnableEvents = True
End Sub