PDA

View Full Version : Solved: Populating Textbox 2 on the basis of Textbox 1



hdevadiga
10-09-2012, 11:24 PM
Hi Friend,

While working on this file, i got an error.. In this file i have a userform which contain TextBox1, TextBox2 and Submit... I use the data range of A1:B7 in this which is mentioned below:

A B
Emp Code Deparment
1001 HR
1002 Finance
1003 Sales

My query is when i type "1001" in textbox1 than i should get "HR" automatically in textbox2 and when i click on submit button it should save in "Data" sheet.... Please help

Regards,
Hari

Bob Phillips
10-10-2012, 12:09 AM
Private Sub TextBox1_AfterUpdate()
On Error Resume Next
TextBox2.Value = Application.VLookup(Val(TextBox1.Value), Worksheets("Data").Range("A1:B7"), 2, False)
On Error GoTo 0
End Sub

hdevadiga
10-10-2012, 12:15 AM
Thanks friend XLD......