Creating a named range?

D

dksaluki

Could someone please help? I'm having trouble creating a named range,
and adding that range to a ComboBox. The range that I want to add is
horizontal, cells A1:E1, calling it "Test". When I add "Test" to
ComboBox by doing ComboBox1.ListFillRange = "Test", it only shows A1
in the dropdown. But when I change the named range to VERTICAL,
cells A1:A5, everything works out perfectly. Can you not create
horizontal named ranges? Are my ComboBox properties not set
right?....
Please help.

DK
 
J

Jim Rech

The list fill range must be vertical. If you insist on a horizontal range
you'll have to populate the combobox by a macro. This example code assumes
the combobox is on a worksheet.

Sub FillCombo()
Dim Cell As Range
With Worksheets("Sheet1")
For Each Cell In .Range("Test")
.ComboBox1.AddItem Cell.Value
Next
End With
End Sub

The combobox will not remember the list when the sheet is saved and reopened
so you'd have to run this when the workbook is opened. Better just to go
with a vertical list.

--
Jim
| Could someone please help? I'm having trouble creating a named range,
| and adding that range to a ComboBox. The range that I want to add is
| horizontal, cells A1:E1, calling it "Test". When I add "Test" to
| ComboBox by doing ComboBox1.ListFillRange = "Test", it only shows A1
| in the dropdown. But when I change the named range to VERTICAL,
| cells A1:A5, everything works out perfectly. Can you not create
| horizontal named ranges? Are my ComboBox properties not set
| right?....
| Please help.
|
| DK
|
 
D

dksaluki

ok, i will try to use vertical list.

i did also try the .AddItem method to add each cell item to the
combobox list. I got a "permission denied error"! story of my life!
...BUT that's another problem.

thanks. i will use vertical list.

dk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top