Could not set the RowSource property. Invalid property value

Denny57

Board Regular
Joined
Nov 23, 2015
Messages
235
Office Version
  1. 365
Platform
  1. Windows
I have tried to add a range into a combobox both by using VBA code and control properties but cannot get the details to be accepted.

When I add a range (eg Sheet1!M3:M11) in the control properties (Row Source) I get the abovre error message

When I try to add the code using VBA in the initialize macro, the User Form will not open and an error is reported at the module level, which from experience means that there is a generic error in the code. As soon as I remove the code, the user form opens.

Sample Codes which stop the user from from opening

Dim listdetails as Variant
'listdetails = Range("Sheet2!M3:M11")
'cbo1.List = listdetails
ALSO
Dim listdetails as Variant
'listdetails = Range("Sheet2!M3:M11")
'cbo1.RowSource= listdetails

Any help would be appreciated
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Must be some other aspect of your code that's not gelling with what you posted. I had no sheet/range/combobox name like that but this modified code worked no problem. You should probably post all of the event. Please use code tags (vba button on posting toolbar) to maintain indentation and readability if you post code.
VBA Code:
Private Sub UserForm_Initialize()
Dim listdetails As Variant
listdetails = Range("Sheet2!I4:I10")
ComboBox1.List = listdetails
End Sub
 
Upvote 0
Must be some other aspect of your code that's not gelling with what you posted. I had no sheet/range/combobox name like that but this modified code worked no problem. You should probably post all of the event. Please use code tags (vba button on posting toolbar) to maintain indentation and readability if you post code.
VBA Code:
Private Sub UserForm_Initialize()
Dim listdetails As Variant
listdetails = Range("Sheet2!I4:I10")
ComboBox1.List = listdetails
End Sub
Micron

Thanks for your help with this but apart from a couple of extraneous apostrophes in my examples, there is no difference in the code.

As I have indicated. if I "hide" the ComboBox code then the user form works fine.

I cannot understand why the control properties will not accept the correctly formatted source.
 
Upvote 0
As soon as I remove the code, the user form opens.
That indicates the problem is in your code. Not sure why you think one or two "extraneous" apostrophes don't seem to matter.
I cannot understand why the control properties will not accept the correctly formatted source.
Then maybe it's not correct? What are you putting there?
 
Upvote 0
Rowsource needs an address string, not a range object, so:

VBA Code:
listdetails = "Sheet2!M3:M11"
cbo1.RowSource= listdetails
 
Upvote 0
But the list property will accept a range object, which didn't work for OP but worked for me?
 
Upvote 0
which didn't work for OP but worked for me
OP stated there was no difference between your code and his other than apostrophes, so I am assuming he didn't actually try the List property.
 
Upvote 0
Ah, I didn’t spot that in the original post!
 
Upvote 0
Hi

What is frustrating me is that I have used the same syntax in multiple ComboBoxes in multiple files and have double-checked the way that I have populated the Row Source and Control source fields in ComboBox properties in these files.

It is almost as if Office 365 has made a change which prevents this property from being populated, regardless of via the properties or via VBA code. It would appear that my only option will be to replace Comboboxes with Textboxes.

Just to confirm that the source formats are the same in all files, which is what does not make any sense.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,195
Members
452,616
Latest member
intern444

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