Populating combobox with named range, but only one item in range

alfordtp

Board Regular
Joined
Oct 3, 2008
Messages
62
I'm using the following for populating a combobox list

me.mn2.list = range("MFG2").value

This usually works, but sometimes there are cases where that named range only has one value in it. VBA is giving me an error with this.

"Run-time error 381: could not set the list property. invalid array index."

Is there a reason for this? Do I have to check every time whether there is more than one item? Hope not, that seems to be excessive.

thoughts?

Thanks in advance!

Tim
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
I do not believe that is a proper named range.

When excel see's
MFG2
It thinks of this as a cell not a named range
 
Upvote 0
MFG2 is a named range in my workbook. I've used this protocol for populating combo boxes before and it works perfectly. This works when there are more than one entry in the named range.
 
Upvote 0
Are you using this in an old xls file?
 
Upvote 0
After some more extensive searching, I found that you can count the items in the range, and if it equals 1, then add the item individually. If it is greater than 1, then I can use the method that I describe above.

thanks for your help anyway.
 
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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