Listbox Error with only 5 columns (Could not set list property. Invalid property error)

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
437
Good day,

I have two userforms - the first has a listbox with the column count set at 5, the second a combination of textboxes, labels, and comboboxes that the user selects. When selection is complete and a button is clicked, the listbox on the first userform is updated with the choices - pretty simple right? Well, the listbox is updated correctly the first 4 of the 5 columns and I can't understand why it won't accept the last column.

Here's the code - I wonder if someone could lend some visibility here.

VBA Code:
Private Sub iSubmit_CLick()

Dim frm As Object

For Each frm In VBA.UserForms
    If frm.Name = "WorkOrderGUI" Then
            With frm.lbAttachments
                .AddItem
                'Checking for column count
                MsgBox .ColumnCount 'Returns 5 so all good there
                .List(.ListCount - 1, 0) = Me.lblItem
                .List(.ListCount - 1, 1) = Me.cbDocType
                .List(.ListCount - 1, 2) = Me.tbDescription
                .List(.ListCount - 1, 3) = Me.tbPath
                .List(.ListCount - 1, 4) = Me.cbJobTask  'Fails here (Invalid property value)
                .BackColor = vbGreen
            End With
    End If
Next frm

End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Maybe you have tio use
Rich (BB code):
 .List(.ListCount - 1, 4) = Me.cbJobTask.Value  'Fails here (Invalid property value)
?
 
Upvote 0
Hi Anthony47,

Yeah, tried that but to know avail - for the life of me I can't figure out why the indexes 0-3 work and the 4 index does not. Very odd. I even put "Me.cbJobTask" in the index 3 position and Me.tbPath in the index 4 position, the listbox accepted Me.cbJobTask in index 3 but again failed at index 4.
 
Upvote 0
What happens if you reverse the position?
VBA Code:
                .List(.ListCount - 1, 4) = Me.tbPath
                .List(.ListCount - 1, 3) = Me.cbJobTask  'Fails here (Invalid property value)
 
Upvote 0
Indeed you had already given an answer, in your message #3 :mad:

I suggest that you insert a new Listbox, with the same properties of your current lbAttachments; then delete the current one an rename the new one as lbAttachments; maybe that object got corrupted. If you try, do that on a copy of your original workbook

Bye
 
Upvote 0
It continues to fail at index 4 no matter what order I place it in.

Try adding line shown in bold & see if resolves your issue

Rich (BB code):
Private Sub iSubmit_CLick()

Dim frm As Object

Me.cbJobTask.MatchRequired = False

For Each frm In VBA.UserForms
    If frm.Name = "WorkOrderGUI" Then
            With frm.lbAttachments
                .AddItem
                'Checking for column count
                MsgBox .ColumnCount 'Returns 5 so all good there
                .List(.ListCount - 1, 0) = Me.lblItem
                .List(.ListCount - 1, 1) = Me.cbDocType
                .List(.ListCount - 1, 2) = Me.tbDescription
                .List(.ListCount - 1, 3) = Me.tbPath
                .List(.ListCount - 1, 4) = Me.cbJobTask  'Fails here (Invalid property value)
                .BackColor = vbGreen
            End With
    End If
Next frm

End Sub

Dave
 
Upvote 0
So mystery solved (I think). Originally I had 4 columns in the listbox and two items already in the listbox. Requirements changed and I had to add a 5th column. When I tried to add a third item, it would give me the error, so when I removed the two and added all three again, there was no problem.

Thanks for your suggestions and taking the time to provide them.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,331
Members
452,636
Latest member
laura12345

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