Hello.
I have a userform with 2 parts, the 2nd part originally I have 10 text boxes and with a add button, the data with then show on the listbox, code as below
Private Sub CommandbuttonAdd_Click()
arrctrls = Array(txtbox1, txtbox2, txtbox3, txtbox4, txtbox5, txtbox6, txtbox7, txtbox8, txtbox9, txtbox10)
With ListBox1
.AddItem
For i = LBound(arrctrls) To UBound(arrctrls)
.List(.ListCount - 1, i) = arrctrls(i).Value
Next i
End With
It works perfectly however now I need to add 8 more text boxes.
Listbox Additems only can show max 10 columns.
I try to search online, find something like this, but dont know how to apply in my case.
Especially the "Textbox" & i, since I have more textbox in part 1, seems it can't work.
I need to add new data in the excel sheet through the userform, so cannot use RowSource method.
Can anyone help to modify? Thank you very much.
Private Sub CommandbuttonAdd_Click()
With Listbox1
.Additem
For i= 1 to 18
.List (.ListCount -1, i-1)= Me.Controls("TextBox" & i). Value
-----------------
Private Sub UserForm_Initialize ()
With Me. List Box1
.ColumnCount = 18
.List = range (cells(1,1), Cells(1, .ColumnCount)).Value
End With
Bookmarks