Please help with code?

G

Greg

How do I set up the text box. I currently am using the exit code and when i
leave a box when is empty it comes up with the invalid code message box. I
tried the key press code and it comes up with the invalide code in between
key presses.

What should I use?


Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim ans

On Error Resume Next
ans = Application.Match(TextBox3.Text, Range("c:c"), 0)

If Not IsError(ans) Then
TextBox1.Text = Application.Index(Range("a:a"), ans)
TextBox2.Text = Application.Index(Range("b:b"), ans)
TextBox4.Text = Application.Index(Range("a:a"), ans)
TextBox5.Text = Application.Index(Range("b:b"), ans)
TextBox6.Text = Application.Index(Range("C:C"), ans)
TextBox7.Text = Application.Index(Range("D:D"), ans)
TextBox8.Text = Application.Index(Range("E:E"), ans)
TextBox9.Text = Application.Index(Range("F:F"), ans)
TextBox10.Text = Application.Index(Range("G:G"), ans)
TextBox11.Text = Application.Index(Range("H:H"), ans)
TextBox12.Text = Application.Index(Range("I:I"), ans)
Else
MsgBox "NOT IN LIST"
End If
On Error GoTo 0
End Sub
Thanks in advance

Greg
 
D

Dave Peterson

If they have to enter something that matches column C in textbox3, why not just
make textbox3 a combobox?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Name look up 1
Error control? 2
Advice Please? 3
Help with code please? 2
Help with code please 1
Help with code please? 6
Help with code please 4
Help with code please 4

Top