ListBox Run-Time Error

Rocky0201

Active Member
Joined
Aug 20, 2009
Messages
278
Hi,

I am having problems with populating 11 columns in my ListBox6.

The following code gives me a Run-Time error 380 "Could not set the List property. Invalid property value." when I am creating column 11 .List(.ListCount - 1, 10) = Me.ListBox5.List(x, 8) . If I were to remove the statement (make it a comment) the code executes fine and 10 columns are created.

Note: I create the information if the array V for debugging. All 11 entries in V are corrrect.

In advance, thanks for the help.

Code:
    '// Since .List is 0-based,skip the first row in the listbox  //
    For x = 1 To Me.ListBox5.ListCount - 1
 
        If ComboBox6.Value = Me.ListBox5.List(x, 0) & "-" & Me.ListBox5.List(x, 8) Then
            ReDim V(10)
 
            V(0) = ComboBox8.Value
            V(1) = ComboBox5.Value
            V(2) = Me.ListBox5.List(x, 0)
            V(3) = Me.ListBox5.List(x, 1)
            V(4) = Me.ListBox5.List(x, 2)
            V(5) = Format(Me.ListBox5.List(x, 3), "00000")
            V(6) = Me.ListBox5.List(x, 4)
            V(7) = Format(Me.ListBox5.List(x, 5), "mm/dd/yyyy")
            V(8) = Format(Me.ListBox5.List(x, 6), "hh:mm AM/PM")
            V(9) = Me.ListBox5.List(x, 7)
            V(10) = Me.ListBox5.List(x, 8)
            With ListBox6
                .ColumnCount = 11
                .ColumnHeads = False
                .ColumnWidths = "15;30;30;100;30;35;55;60;55;100;20"
                .AddItem ComboBox8.Value
                .List(.ListCount - 1, 1) = ComboBox5.Value
                .List(.ListCount - 1, 2) = Me.ListBox5.List(x, 0)
                .List(.ListCount - 1, 3) = Me.ListBox5.List(x, 1)
                .List(.ListCount - 1, 4) = Me.ListBox5.List(x, 2)
                .List(.ListCount - 1, 5) = Format(Me.ListBox5.List(x, 3), "00000")
                .List(.ListCount - 1, 6) = Me.ListBox5.List(x, 4)
                .List(.ListCount - 1, 7) = Format(Me.ListBox5.List(x, 5), "mm/dd/yyyy")
                .List(.ListCount - 1, 8) = Format(Me.ListBox5.List(x, 6), "hh:mm AM/PM")
                .List(.ListCount - 1, 9) = Me.ListBox5.List(x, 7)
                .List(.ListCount - 1, 10) = Me.ListBox5.List(x, 8)
            End With
        End If
    Next
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
if you use additem, you can only use 10 columns. assign an array to the List property instead.
 
Upvote 0
Rory,

Thanks for the response.

Please let me know your meaning of assign an array to the List property. I am not certain how this code should look.

Thanks again.
 
Upvote 0
For example
Code:
listbox6.list = V
though you will need to alter the code to populate V with all the rows of data from the other listbox first, rather than doing 1 at a time.
 
Upvote 0
For example
Code:
listbox6.list = V
though you will need to alter the code to populate V with all the rows of data from the other listbox first, rather than doing 1 at a time.
 
Upvote 0

Forum statistics

Threads
1,215,753
Messages
6,126,677
Members
449,327
Latest member
John4520

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