Reputation: 79
I have a simple userform that has 2 textboxes. 1 for a job entry, 1 for a location display.
I want to track the location of parts by scanning a barcode every time they get to a new location in our facility. This means that I may have the same barcode # like 4 or 5 times.
In my userform, when the user either types in a job number, or scans a barcode into that first textbox, the second textbox is going to show the last recorded location of the part.
The code I've written seems to only find the first time the job number is recorded though... I'm unsure how to get it to search from the bottom up, rather than the top down.
Can anyone advise? I'm having a lot of trouble figuring out how to populate userforms with data already written on a sheet. Any advice or direction to reading materials specifically regarding this would be much appreciated!
Here is my code:
Private Sub txtSCAN_BARCODE_FIND_Change()
'LOOP THROUGH DATABASE AND FIND THE PART LOCATION
Dim WS As Worksheet
Set WS = ThisWorkbook.Sheets("DATABASE")
WSLR = WS.Cells(Rows.Count, 1).End(xlUp).Row
For X = 2 To WSLR
'This is the job number we're looking for
If WS.Cells(X, 1) = Me.txtSCAN_BARCODE_FIND Then
'This is where the last recorded position is going to display
Me.txtLOCATION_FIND = WS.Cells(X, "F")
Exit Sub
End If
Next X
End Sub
Upvotes: 0
Views: 398