populate data in multiple textbox based on select from listbox

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
i would some help to adjusting my code i have data in my sheet 18 columns and i have 18 textbox on userform and another texbox for searching and show result in listbox1 when i search it shows the data in listbox but when i click data in listbox it doesn't show anything in multiple textbox
VBA Code:
Private Sub ListBox1_Click()
If Me.ListBox1.ListIndex = -1 Then
ElseIf Me.ListBox1.ListIndex >= 1 Then
r = Me.ListBox1.ListIndex
With Me
.TextBox1.Value = ListBox1.List(r, 0)
.TextBox2.Value = ListBox1.List(r, 1)
.TextBox3.Value = ListBox1.List(r, 2)
.TextBox4.Value = ListBox1.List(r, 3)
.TextBox5.Value = ListBox1.List(r, 4)
.TextBox6.Value = ListBox1.List(r, 5)
.TextBox7.Value = ListBox1.List(r, 6)
.TextBox8.Value = ListBox1.List(r, 7)
.TextBox9.Value = ListBox1.List(r, 8)
.TextBox10.Value = ListBox1.List(r, 9)
.TextBox11.Value = ListBox1.List(r, 10)
.TextBox12.Value = ListBox1.List(r, 11)
.TextBox13.Value = ListBox1.List(r, 12)
.TextBox14.Value = ListBox1.List(r, 13)
.TextBox15.Value = ListBox1.List(r, 14)
.TextBox16.Value = ListBox1.List(r, 15)
.TextBox17.Value = ListBox1.List(r, 16)
.TextBox18.Value = ListBox1.List(r, 17)
End With
End If
end sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Forum statistics

Threads
1,214,830
Messages
6,121,834
Members
449,051
Latest member
excelquestion515

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