Thread: Auto look up
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Greg[_20_] Greg[_20_] is offline
external usenet poster
 
Posts: 58
Default Auto look up

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