Forum Discussion
oteixeira62
Jan 15, 2023Copper Contributor
Populate textbox with cell value selected in listbox in a different column
Hello to all, I’m trying to adapt the VBA code to populate the userform TextBox2 with a value located in a non-contiguous, different column, as explained in the picture bellow. This is the...
- Jan 15, 2023
Try this version of ListBox1_Click:
Private Sub ListBox1_Click() Dim s As String If Me.ListBox1.ListIndex >= 0 Then 'User has selected s = Application.VLookup(Me.ListBox1.Value, Worksheets("Tabelas").Range("A:H"), 8, False) Me.TextBox1.Value = s End If End Sub
HansVogelaar
Jan 15, 2023MVP
Try this version of ListBox1_Click:
Private Sub ListBox1_Click()
Dim s As String
If Me.ListBox1.ListIndex >= 0 Then 'User has selected
s = Application.VLookup(Me.ListBox1.Value, Worksheets("Tabelas").Range("A:H"), 8, False)
Me.TextBox1.Value = s
End If
End Sub- oteixeira62Jan 15, 2023Copper ContributorOne again Hans, Your help is precious,
Many thanks!
Octavio