Hi,
I am having problems trying to get the below to work, when I scan the barcode it stops after the first digit I have tried other subs with no joy can anyone help. I just want it to show error msg if the length of the barcode is wrong.
Regards
I am having problems trying to get the below to work, when I scan the barcode it stops after the first digit I have tried other subs with no joy can anyone help. I just want it to show error msg if the length of the barcode is wrong.
VBA Code:
Private Sub textbox2_Change()
Dim erow As Long
Application.DisplayAlerts = False
If Len(TextBox2.Value) < 46 Then
MsgBox "Too short!"
Else
If Len(TextBox2.Value) > 46 Then
erow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 2) = TextBox1.Text
Cells(erow, 3) = TextBox2.Text
Cells(erow, 7) = TextBox3.Text
Cells(erow, 8) = TextBox4.Text
Range("A" & Rows.Count).End(xlUp).Offset(1).Value = Date
Cells(erow, 4).FormulaR1C1 = "=mid(rc[-1],4,4)"
Cells(erow, 5).FormulaR1C1 = "=mid(rc[-2],8,4)"
Cells(erow, 6).FormulaR1C1 = "=mid(rc[-3],30,6)"
TextBox2.Text = ""
TextBox3.Text = ""
TextBox2.Visible = True
TextBox4.Text = ""
TextBox1.Visible = True
TextBox3.Visible = False
TextBox4.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Label6.Visible = False
Range("A1").End(xlDown).Select
Application.DisplayAlerts = True
TextBox2.SetFocus
End If
End If
End Sub
Regards