listbox column1 values populates textboxes

asyamonique

Well-known Member
Joined
Jan 29, 2008
Messages
1,286
Office Version
  1. 2013
Platform
  1. Windows
Code:
Private Sub ComboBox1_Change()
Dim a, i As Long, ii As Long, b(), n As Long
With ComboBox1
If .Text = "" Then Exit Sub
If WorksheetFunction.CountIf(Worksheets("info").Range("a:a"), .Text) = 0 Then
MsgBox "No Entry !"
Exit Sub
End If
a = Worksheets("info").Range("a1").Resize(Worksheets("info").Range("a" & Rows.Count).End(xlUp).Row, 25).Value
For i = 1 To UBound(a, 1)
If a(i, 1) = .Text Then
n = n + 1: ReDim Preserve b(1 To 25, 1 To n)
For ii = 1 To UBound(a, 2)
b(ii, n) = a(i, ii)
Next
End If
Next
End With
With ListBox1
.ColumnCount = 25
.ColumnWidths = "0;50;50;50;50,50;50;50;50;50;50;50;50,50;50;50;50;50;50;50;50;50,50;50;50"
.Column = b
End With
End Sub

Good Day,
How can i populate the column1 values from given code above into the textboxes in order from textbox1 to textbox20 on my userform while the listbox change event?
Many thanks
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You dont have any Textboxes in your code - only a combobox and a listbox!!! - you should indent your code - so it is more readable - it is very hard to follow
 
Upvote 0
You dont have any Textboxes in your code - only a combobox and a listbox!!! - you should indent your code - so it is more readable - it is very hard to follow
Yes I don't have any TextBoxes in my code coz i don't need it!
The given code simply populating the listbox into the 25 columns by a combobox.I have no problem with that.What i need below the listbox i have textboxes from 1 to 20....
When the listbox gives me the result the below 20 textboxes will be load with column1 datas from first row to down in same order..Thats the one i was going to be needed.
Actually it will be like
Code:
Private Sub ListBox3_Change()
Me.TextBox1.Value = Me.ListBox1.Column(0)
End Sub
But with that code the change event can't populate the textbox correctly due to the user should select the row by clicking to listbox.
Hope its clear for you.
Cheers,
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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