Populating combobox with range

Glove303

Board Regular
Joined
Dec 18, 2010
Messages
65
I get an error if I try and populate a combobox with a range that only has one cell of data in it. If multiple cells have data it works fine.

Why is this?

Code:
Me.Tech_Com.List = Techniques.Range(Techniques.Cells(5, 1), _
Techniques.Cells(LastRowTech, 1)).Value
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
xl2007's Help article for List Property includes this note:

Use List to copy an entire two-dimensional array of values to a control. Use AddItem to load a one-dimensional array or to load an individual element.

So using .List for a single cell returns an error.
 
Upvote 0
That seems a bit poor that list can't handle one item. So the only solution is to have an if statement that checks if there is just one item, and if so uses additem, otherwise it uses list?

I'm glad I've discovered this, as I have lots of other code that is going to crash if my users delete entries and the column just has 1 entry!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,718
Members
452,939
Latest member
WCrawford

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