kapela2017
New Member
- Joined
- Oct 16, 2022
- Messages
- 33
- Office Version
- 365
- Platform
- Windows
Greetings, I wonder if you can guide me, I'm trying to make a texbox ("Textbox2") return me automatically ("Change Event") the result of a search ("VlooKup") based on the data of another texbox(" Textbox1"),Both texboxes are in a Userform("Userform1"), The data is in a Table("ListObjects") I tried the Control Source property without success, pay attention to your advice....
b
VBA Code:
Private Sub TextBox2_Change()
Dim Tabla1 As ListObject
Set Tabla1 = ThisWorkbook.Worksheets("hoja1").ListObjects("Tabla1")
Dim codigo As Range
Set codigo = Tabla1.ListColumns("codigo").DataBodyRange
Dim nro As Range
Set nro = Tabla1.ListColumns("nro").DataBodyRange
Me.Controls("TextBox2").Value = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), Tabla1.ListColumns("codigo").DataBodyRange, Tabla1.ListColumns("nro").DataBodyRange, 2, 0)
End Su