Help with code please?

G

Greg B

Hi all,
I am looking for help on this code, I have a userform where it looks up a
number and give the information on the person associated with this number.
Here is the code for this.

Private Sub ComboBox1_Change()
Dim ans

On Error Resume Next


ans = Application.Match(CLng(ComboBox1.Text), Range("A:A"), 0)
If Not IsError(ans) Then
Label1.Caption = Application.Index(Range("b:b"), ans)
Label2.Caption = Application.Index(Range("c:c"), ans)
Else
MsgBox "Invalid code"
End If
On Error GoTo 0

End Sub

I have included a 5 textboxes, textbox1 etc and I want the userform to have
a commandbutton when it is pressed to have the information in the textboxes
to be put in to columns E to I in order textbox1 to "e" etc. I have no
idea how to do this.

Thanks

Greg
 
A

Ardus Petus

,---------------------------------------------
Private Sub ComboBox1_Change()
Dim ans

On Error Resume Next


ans = Application.Match(CLng(ComboBox1.Text), Range("A:A"), 0)
If Not IsError(ans) Then
Label1.Caption = Cells(ans, "B")
Label2.Caption = Cells(ans, "C")
Else
MsgBox "Invalid code"
End If
On Error GoTo 0

End Sub
'---------------------------------------------

HTH
 

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

Advice Please? 3
Help with code please 1
Please help with code? 2
Adding two values 3
Help Please 0
Help with code please 4
Advice on code 0
Error control? 2

Top