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

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
354
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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,274
Maybe you have tio use
Rich (BB code):
 .List(.ListCount - 1, 4) = Me.cbJobTask.Value  'Fails here (Invalid property value)
?
 

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
354
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.
 

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,274
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)
 

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
354

ADVERTISEMENT

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

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,274
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
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
7,042
Office Version
  1. 2019
Platform
  1. Windows
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
 

RawlinsCross

Active Member
Joined
Sep 9, 2016
Messages
354
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.
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,576
Messages
5,765,194
Members
425,266
Latest member
CPAgirl

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
Top