TextBoxes populates by a listbox.

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
Code:
Private Sub ListBox1_Click()
With Me.ListBox1
Me.TextBox21.Value = .list(.ListCount - 20, 0)
Me.TextBox22.Value = .list(.ListCount - 19, 0)
Me.TextBox23.Value = .list(.ListCount - 18, 0)
Me.TextBox24.Value = .list(.ListCount - 17, 0)
Me.TextBox5.Value = .list(.ListCount - 16, 0)
Me.TextBox6.Value = .list(.ListCount - 15, 0)
Me.TextBox7.Value = .list(.ListCount - 14, 0)
Me.TextBox8.Value = .list(.ListCount - 13, 0)
Me.TextBox9.Value = .list(.ListCount - 12, 0)
Me.TextBox10.Value = .list(.ListCount - 11, 0)
Me.TextBox11.Value = .list(.ListCount - 10, 0)
Me.TextBox12.Value = .list(.ListCount - 9, 0)
Me.TextBox13.Value = .list(.ListCount - 8, 0)
Me.TextBox14.Value = .list(.ListCount - 7, 0)
Me.TextBox15.Value = .list(.ListCount - 6, 0)
Me.TextBox16.Value = .list(.ListCount - 5, 0)
Me.TextBox17.Value = .list(.ListCount - 4, 0)
Me.TextBox18.Value = .list(.ListCount - 3, 0)
Me.TextBox19.Value = .list(.ListCount - 2, 0)
Me.TextBox20.Value = .list(.ListCount - 1, 0)
End With
End Sub

Good Day
Is there any way to alter that given code.
If the list index has 20rows and above it works fine.
But if the row amount reduce giving me the below error...
Run-time error ‘381’:
“Could not get the List property.Invalid property array index.”
How can i avoid that error?
Many Thanks

 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I just want to change the target of the textboxes.
That code populates the textboxes with datas from bottom of the listbox list and going up..
How can we change it from top the down?
Its like first row data will be in first textbox then all the way down as in listbox!
Thanks again
 
Upvote 0
Finally found the solution.
Cheers.
Code:
On Error Resume Next
With Me.ListBox1
Me.TextBox1.Value = Me.ListBox1.Column(0, 0)
Me.TextBox2.Value = Me.ListBox1.Column(0, 1)
Me.TextBox3.Value = Me.ListBox1.Column(0, 2)
Me.TextBox4.Value = Me.ListBox1.Column(0, 3)
Me.TextBox5.Value = Me.ListBox1.Column(0, 4)
Me.TextBox6.Value = Me.ListBox1.Column(0, 5)
Me.TextBox7.Value = Me.ListBox1.Column(0, 6)
Me.TextBox8.Value = Me.ListBox1.Column(0, 7)
Me.TextBox9.Value = Me.ListBox1.Column(0, 8)
Me.TextBox10.Value = Me.ListBox1.Column(0, 9)
Me.TextBox11.Value = Me.ListBox1.Column(0, 10)
Me.TextBox12.Value = Me.ListBox1.Column(0, 11)
Me.TextBox13.Value = Me.ListBox1.Column(0, 12)
Me.TextBox14.Value = Me.ListBox1.Column(0, 13)
Me.TextBox15.Value = Me.ListBox1.Column(0, 14)
Me.TextBox16.Value = Me.ListBox1.Column(0, 15)
Me.TextBox17.Value = Me.ListBox1.Column(0, 16)
Me.TextBox18.Value = Me.ListBox1.Column(0, 17)
Me.TextBox19.Value = Me.ListBox1.Column(0, 18)
Me.TextBox20.Value = Me.ListBox1.Column(0, 19)
End With
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,752
Members
452,940
Latest member
rootytrip

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