Auto look up

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

I use this code below to look up a number in a sheet
I was wanting to extend this to be able to have both textbox1 and textbox2
to have the look up ability




Private Sub TextBox1_Enter()

Dim ans

On Error Resume Next
ans = Application.Match(CLng(TextBox1.Text), Range("A1:A100"), 0)
If Not IsError(ans) Then
TextBox2.Text = Application.Index(Range("B1:B100"), ans)
TextBox3.Text = Application.Index(Range("C1:C100"), ans)
Else
MsgBox "Invalid code"
End If
On Error GoTo 0
End Sub

Thanks

Greg
 
Back
Top