abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,429
- Office Version
- 2019
- 2010
- Platform
- 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