elsg
08-21-2015, 07:18 AM
I have EAN in tab (BD_Prod) and i have UserForm (frmCadAva), when i enter correct EAN in txtEan work well, but i clear and enter wrong EAN not displaymessage.
I need VLookUp (inside Userform), run all time to verify correct or worng entered on textbox (txtEan).
Private Sub txtEan_Exit(ByVal Cancel As MSForms.ReturnBoolean)If Len(txtEan.Text) >= 7 Then
On Error Resume Next
form1 = WorksheetFunction.VLookup(Val(txtEan.Text), Worksheets("BD_Prod").Range("A1:D100000"), 2, 0)
form2 = WorksheetFunction.VLookup(Val(txtEan.Text), Worksheets("BD_Prod").Range("A1:D100000"), 3, 0)
form3 = WorksheetFunction.VLookup(Val(txtEan.Text), Worksheets("BD_Prod").Range("A1:D100000"), 4, 0)
If Err.Number = 0 Then
txtCod.Text = form1
txtDesc.Text = form2
txtVlrUnit.Text = form3
Else
txtEan.Text = "EAN not found"
On Error Resume Next
End If
On Error GoTo 0
End If
Me.txtEan.BackColor = RGB(255, 255, 255)
End Sub
I need VLookUp (inside Userform), run all time to verify correct or worng entered on textbox (txtEan).
Private Sub txtEan_Exit(ByVal Cancel As MSForms.ReturnBoolean)If Len(txtEan.Text) >= 7 Then
On Error Resume Next
form1 = WorksheetFunction.VLookup(Val(txtEan.Text), Worksheets("BD_Prod").Range("A1:D100000"), 2, 0)
form2 = WorksheetFunction.VLookup(Val(txtEan.Text), Worksheets("BD_Prod").Range("A1:D100000"), 3, 0)
form3 = WorksheetFunction.VLookup(Val(txtEan.Text), Worksheets("BD_Prod").Range("A1:D100000"), 4, 0)
If Err.Number = 0 Then
txtCod.Text = form1
txtDesc.Text = form2
txtVlrUnit.Text = form3
Else
txtEan.Text = "EAN not found"
On Error Resume Next
End If
On Error GoTo 0
End If
Me.txtEan.BackColor = RGB(255, 255, 255)
End Sub