silva_jmp
12-10-2012 14:55:12
Estou usando este código.
Código: Selecionar todos
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'Limita a Qde de caracteres
TextBox1.MaxLength = 10
'para permitir que apenas números sejam digitados
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
KeyAscii = 0
End If
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim ws As Worksheet
Set ws = Sheets("Plan2")
If TextBox1 = "" Then
Exit Sub
End If
On Error GoTo ErroMAT:
lin = Application.WorksheetFunction.Match(CInt(TextBox1.Value), ws.Range("A:A"), 0)
TextBox2 = ws.Cells(lin, 2)
Exit Sub
ErroMAT:
TextBox1 = ""
TextBox2 = ""
MsgBox ("Código de Material inválido")
End Sub
silva_jmp