G
Greg
Hi all, I have put below the code I use to look a number that has been
inputted into textbox1. The problem is when there is an illegal code put in
it comes up with the invalid code message box as expected but goes onto the
next textbox. I need it to highlight where the mistake was made.
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim ans
On Error Resume Next
ans = Application.Match(CLng(TextBox1.Text), Range("A:A"), 0)
If Not IsError(ans) Then
TextBox2.Text = Application.Index(Range("B:B"), ans)
TextBox3.Text = Application.Index(Range("C:C"), ans)
TextBox4.Text = Application.Index(Range("D"), ans)
TextBox5.Text = Application.Index(Range("E:E"), ans)
Else
MsgBox "Invalid code"
End If
On Error GoTo 0
End Sub
How do I do this?
Thanks in advance
Greg
inputted into textbox1. The problem is when there is an illegal code put in
it comes up with the invalid code message box as expected but goes onto the
next textbox. I need it to highlight where the mistake was made.
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim ans
On Error Resume Next
ans = Application.Match(CLng(TextBox1.Text), Range("A:A"), 0)
If Not IsError(ans) Then
TextBox2.Text = Application.Index(Range("B:B"), ans)
TextBox3.Text = Application.Index(Range("C:C"), ans)
TextBox4.Text = Application.Index(Range("D"), ans)
TextBox5.Text = Application.Index(Range("E:E"), ans)
Else
MsgBox "Invalid code"
End If
On Error GoTo 0
End Sub
How do I do this?
Thanks in advance
Greg