mahshadrashidpour
New Member
- Joined
- Jul 17, 2023
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hello, I have a list of serial numbers and MMID and Batch number of each serial number .
and I want to build a tool that when one serial number is scanned, the MMID and Batch number are printed on the label.
I have written this code but it doesn't work correctly.
Dim i As Integer
For i = 1 To 2
Dim a
Dim Rng As Range
Dim lr As Long
a = InputBox("Please scan the serial number") 'Inserting serial Number
If Trim(a) <> "" Then
With Sheets("MMIDs").Range("A:A") 'searches the serial number all of column A
Set Rng = .Find(What:=a, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True 'value found
lr = Sheets("Result").Cells(Rows.Count, "A").End(xlUp).Row + 1 'Find first blank row on new sheet
Application.EnableEvents = False
Sheets("MMIDs").Cells(i, "A").EntireRow.Copy Destination:=Sheets("Result").Range("A" & Rows.Count).End(xlUp).Offset(1)
Else
MsgBox "Serial Number Not found" 'value not found
End If
End With
End If
Next i
End Sub
and I want to build a tool that when one serial number is scanned, the MMID and Batch number are printed on the label.
I have written this code but it doesn't work correctly.
Dim i As Integer
For i = 1 To 2
Dim a
Dim Rng As Range
Dim lr As Long
a = InputBox("Please scan the serial number") 'Inserting serial Number
If Trim(a) <> "" Then
With Sheets("MMIDs").Range("A:A") 'searches the serial number all of column A
Set Rng = .Find(What:=a, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True 'value found
lr = Sheets("Result").Cells(Rows.Count, "A").End(xlUp).Row + 1 'Find first blank row on new sheet
Application.EnableEvents = False
Sheets("MMIDs").Cells(i, "A").EntireRow.Copy Destination:=Sheets("Result").Range("A" & Rows.Count).End(xlUp).Offset(1)
Else
MsgBox "Serial Number Not found" 'value not found
End If
End With
End If
Next i
End Sub
Serial | MMID | Batch Number |
PHWL724401GL160MGN | 927199 | TWPH76P215 |
PHWL7244017U160MGN | 927199 | TWPH76P215 |