Unspecified error trying to load Listbox

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,422
Office Version
  1. 2016
Platform
  1. Windows
I am loading a Listbox on a Userform like so;

Code:
With Me.ListBox1
.ColumnCount = 10
.ColumnHeads = True
.ColumnWidths = "40;50;110;60;55;60;60;60;0;0"
.RowSource = Sheet1.Range("A2:M" & LastRow).Address(, , , True)
End With

Most of the time it works fine, but regularly it gives me an error when I try to load it, this comes after I have changed sheet values - the error is simply;

2147467259 (80004005) Could not set the rowsource property - Unspecified Error

I have a possible solution suggested after a Google search which is to set the Listbox to load from an array but I have no idea how to do this if someone can help?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Replace this line:

Code:
.RowSource = Sheet1.Range("A2:M" & LastRow).Address(, , , True)

with this:

Code:
.List = Sheet1.Range("A2:M" & LastRow).Value
 
Upvote 0
Thanks Rory, but same error is occurring after I've tried loading the form a few times.

It's odd, because it works fine for say half a dozen times then the problem occur - if I comment the Listbox part of the userform initialize then it works fine so must be something to do with that.
 
Last edited:
Upvote 0
sharky, looking into this it seems on the second run of load it is not collecting any added lines etc.

Lookup listbox requery. I think it may solve your problem
 
Upvote 0
I assume the error message is slightly different since you can't get a Rowsource error when you aren't using the RowSource property.
 
Upvote 0
Slightly different, yes - now it says could not set the List property but same error codes of 2147467259 and (80004005).

Haven't had time yet to look at what Dryver14 has suggested....
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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