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

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
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,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

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