ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   text box look up (https://www.excelbanter.com/excel-discussion-misc-queries/26448-text-box-look-up.html)

Greg B

text box look up
 
I am using a userform with a textbox to look up certain surnames and give me
the people with it, I have asked before about this but the problem I am
having it is only i type the name smith in the box and it comes up with the
first smith in the line. How do I get it to move on until I get the one I
want? I have seen in some programs you type "smith, a " and it comes up
with Alice Smith or something similar.

Here is the code I have been using and have been given extra, can someone
give me advise on how to set it up.

Private Sub TextBox7_AfterUpdate()

Sheets("PRODUCTS").Select

Dim ans

On Error Resume Next

ans = Application.Match(CLng(TextBox7.Text), Range("A:A"), 0)
If Not IsError(ans) Then
TextBox8.Text = Application.Index(Range("B:B"), ans)
TextBox9.Text = Application.Index(Range("C:C"), ans)

Else
MsgBox "Invalid code"
End If
On Error GoTo 0

End Sub

Private Sub TextBox1_AfterUpdate()

Static ans As Long
Dim col As Long
ans = ans + 1
With Sheets("customer")
For col = 1 To 0
Controls("TextBox" & col) = .Cells(ans, col).Value
Next
End With
End Sub

If anyone can help me understand it a little better it would be great.

Thanks in advance

Greg




All times are GMT +1. The time now is 11:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com