mlathem1998
New Member
- Joined
- Feb 11, 2021
- Messages
- 27
- Office Version
- 365
- Platform
- Windows
I had a tool built years back that would allow me to scan badges, then do a vlookup for the associated employee ID, and it time and date stamp the entry. After that pop down to the next line. The first tab is a scanning page with a button to launch the scanning tool, but it is also set to auto load when you open the file. There is a form control has a text box and clear list button. When you scan a badge with the right number of characters, it executes the vba code to find the employee number and drop it in A2. However, I can't get this to reset and it keeps popping up every time after the last entry even after I clear the list. So, I scan a badge, the next cell would be 430, then when I clear the list, it SHOULD go right back to A2. .
Sub Clean_List()
'
' Clean_List Macro
'
'
Columns("A:B").Select
ActiveSheet.Range("$A$1:$B$800").RemoveDuplicates Columns:=Array(1, 2), _
Header:=xlYes
End Sub
Private Sub CommandButton1_Click()
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.ClearContents
Range("A1").Value = "EMPLOYEE ID"
Range("B1").Value = "SCANNED DATE"
TextBox1.SetFocus
Range("A2").Select
End Sub
Private Sub TextBox1_AfterUpdate()
End Sub
Private Sub TextBox1_Change()
If Len(Trim(TextBox1.Text)) = 8 Or TextBox1.Text = "" Then
Range("A1").Select
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -1).Select
ActiveCell.Value = TextBox1.Value
TextBox1.Text = ""
ActiveCell.Offset(-1, 1).Value = DateTime.Now
End If
End Sub
Can anyone help me figure out how to fix this? I know nothing about VBA really.
Sub Clean_List()
'
' Clean_List Macro
'
'
Columns("A:B").Select
ActiveSheet.Range("$A$1:$B$800").RemoveDuplicates Columns:=Array(1, 2), _
Header:=xlYes
End Sub
Private Sub CommandButton1_Click()
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.ClearContents
Range("A1").Value = "EMPLOYEE ID"
Range("B1").Value = "SCANNED DATE"
TextBox1.SetFocus
Range("A2").Select
End Sub
Private Sub TextBox1_AfterUpdate()
End Sub
Private Sub TextBox1_Change()
If Len(Trim(TextBox1.Text)) = 8 Or TextBox1.Text = "" Then
Range("A1").Select
ActiveCell.SpecialCells(xlLastCell).Select
ActiveCell.Offset(1, -1).Select
ActiveCell.Value = TextBox1.Value
TextBox1.Text = ""
ActiveCell.Offset(-1, 1).Value = DateTime.Now
End If
End Sub
Can anyone help me figure out how to fix this? I know nothing about VBA really.