Hello. I'm new to using macros and I'm trying to create one for keeping track of packages within my company's building. I've been able to Frankenstein a usable macro together, but I'm having trouble with the Search.
When we scan the FedEx barcode, it shows the entire code. However, if someone only knows the 12 digit tracking number that is printed on the label, I want to be able to find it within the larger string of numbers.
For instance, if I scan a tracking number, here is what comes out 1002882030350004522700785515984311. However, I want the macro to be able to search for both the long number as well as 785515984311, which is what is printed on the FedEx tracking label.
Also, I don't understand why the message box pops up three times.
Here's my current code below. This searches for the entire code. I've also attached the document.
Private Sub cmdSearch_Click()
Dim x As Long
Dim y As Long
x = Sheets("Worksheet").Range("A" & Rows.Count).End(xlUp).Row
For y = 6 To x
If Sheets("Worksheet").Cells(y, 1).Value = txtSearch.Text Then
txtTracking = Sheets("Worksheet").Cells(y, 1).Value
txtLocation = Sheets("Worksheet").Cells(y, 2).Value
txtReceived = Sheets("Worksheet").Cells(y, 3).Value
txtMoved = Sheets("Worksheet").Cells(y, 4).Value
txtCompleted = Sheets("Worksheet").Cells(y, 5).Value
Else
MsgBox "Tracking Not Found."
txtTracking.SetFocus
End If
Next y
End Sub
Display More
Any assistance would be appreciated.
Thank you,
Becky