Results 1 to 20 of 25

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Feb 2015
    Posts
    36
    Location

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

    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:

    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
    I have attached a sample workbook as well.

    Thank you in advance!
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •