Add a row with more than 10 columns to a ListBox?

onmyway365

New Member
Joined
Sep 18, 2012
Messages
26
Hi guys,

i hope some one can help me. i am really stuck.

I have posted this elsewhere, but as I am struggling to get a working solution, I am also posting here in the hopes of a breakthrough. I will re-link etc. (http://www.excelforum.com/excel-prog...a-listbox.html)

Detail:
i have 12 controls/fields used for capturing data via a UserForm, updating a ListBox that is part of the same UserForm.
However, the problem lies in this: I can only capture 10 columns to the ListBox. I get an error every time the code loops from 10 to the 11th column.

Error: 380: Could not set List property, Invalid Property value.

My code is very simple:
Code:
Private Sub cmdAdd_Click()


        Dim arrCtrls As Variant
        Dim i As Long
        Dim LastRowIndex As Long
        Dim currentReference As RowReference


arrCtrls = Array(TextBox1, TextBox2, TextBox3, TextBox4, TextBox5, TextBox6, TextBox22, TextBox23, TextBox24, TextBox25, TextBox26, TextBox27)


            With ListBox1
                .ColumnCount = UBound(arrCtrls) + 2
                .AddItem
                           
                For i = 0 To UBound(arrCtrls) - 1
                    .List(.ListCount - 1, i) = arrCtrls(i).Value
                Next i
   
End With


End Sub

Thank you in advance!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
If you use AddItem you are limited to 10 columns. You need to create and populate an array and assign that to the List property of the control and then you can use more columns.
 
Upvote 0
Hi Rory,

Thanks for the response.

I have heard this mentioned, but it is a bit hazy. I was told I could make use of a helper sheet for this purpose.

Can you perhaps point me in the right direction?

Thank you very much!
 
Upvote 0
You seem to have plenty of people assisting you on other forums. It would have been nice if you had had the courtesy to provide links to let us know that - see rule 10 here, and especially the link within that rule.
 
Upvote 0

Forum statistics

Threads
1,203,524
Messages
6,055,905
Members
444,832
Latest member
bgunnett8

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