Userform Tab to produce vlookup

drc2265

Board Regular
Joined
Jul 30, 2007
Messages
96
Hello, I have a userform with one textbox that does a vlookup. I have the following code which works when clicking on the box. Is there any way to have this shown when tabbing, or automatically after textbox1 info is entered?

Private Sub UserForm_click()
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("sheet1").Range("a" & row_number)
If item_in_review = TextBox1.Text Then
TextBox2.Text = Sheets("sheet1").Range("B" & row_number)
End If

Loop Until item_in_review = ""
End Sub

Thanks,
DC
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try this. It searches when you exit TextBox1

Code:
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] TextBox1_Exit([color=darkblue]ByVal[/color] Cancel [color=darkblue]As[/color] MSForms.ReturnBoolean)
    [color=darkblue]Dim[/color] Found [color=darkblue]As[/color] Range
    [color=darkblue]Set[/color] Found = Sheets("Sheet1").Range("A:A").Find(TextBox1.Text, , xlValues, xlWhole, 1, 1, 0)
    [color=darkblue]If[/color] [color=darkblue]Not[/color] Found [color=darkblue]Is[/color] [color=darkblue]Nothing[/color] [color=darkblue]Then[/color]
        TextBox2.Text = Found.Offset(, 1).Value
    [color=darkblue]Else[/color]
        TextBox2.Text = ""
    [color=darkblue]End[/color] [color=darkblue]If[/color]
End [color=darkblue]Sub[/color]
 
Upvote 0

Forum statistics

Threads
1,216,131
Messages
6,129,066
Members
449,485
Latest member
greggy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top