Combobox's In a Userform

bonzodog1990

New Member
Joined
Aug 26, 2011
Messages
14
Hi All!

So basically I have a combobox in a userform that I want to be populated by information in a spreadsheet. Easy enough right? Apparently not. I thought the syntax for this was something like:

with *combobox1*
.additem "thing1"
.additem "thing2"

End with

And that works fine, but I want to use pre specified ranges, which i think I've declared properly like this:

dim ccy as range
set ccy as Range("cell1:cell2")

But when I try and use that range to populate my box, none of the syntax's i've found online seem to work. Can you suggest anything?

Additionally, I have this weird bug where I can use identical code for different userforms and it works for some not others. Like, I have a correctly populated combobox written on a test form, and put the same code on my real form, and it doesn't work. Only the names change. I'll screengrab that at work if it makes no sense, but any suggestions appreciated!

Cheers all
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
For the first part, try...

Code:
[font=Verdana]    [color=darkblue]Dim[/color] ccy [color=darkblue]As[/color] Range
    
    [color=darkblue]Set[/color] ccy = Range("A2:A10")
    
    Me.ComboBox1.List = ccy.Value[/font]
 
Upvote 0
Also, you may want to qualify the range reference with the sheet name. For example, if the range of interest is on Sheet1, use the following instead...

Code:
Set ccy = [COLOR="Red"]Worksheets("Sheet1").[/COLOR]Range("A2:A10")
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,480
Members
452,915
Latest member
hannnahheileen

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