Listbox vs Combobox

W

WLMPilot

I am confused as to which option (Listbox or Combobox) to use when.

I am designing a userform to input information pertaining to a flight plan.
Instances where I would use either listbox or combobox would be to:

1) list various airports that are listed on worksheet "Airports"
2) list different planes a pilot is certified to fly

I do not want the user to be able to add to the list. The only way
something can be added is if information about the plane or airport is
entered on a spreadsheet and the combobox/listbox will pick up the new info
automatically.

Can you please explain what the defining difference is between the two
different options so I can decide what to use?

Thanks,
Les
 
M

merjet

They are very similar. A Listbox does not allow
the user to add to the list; a Combobox does but
that property can be disabled in design. Both
allow MatchEntry -- a user can type in letter(s)
and get the first match. Comboboxes usually take
less space, since only one item is shown, except
when the user clicks the drop down arrow.

Hth,
Merjet
 
J

Jim Thomlinson

Both do much the same thing but there are a few nuiances. Generally I use
combo boxes when I expect the user to give a single answer and list boxes
when I expect the user to (possibly) select more than one answer. That being
said it also depends on whether I want the user to see multiple items in the
list of just a single item. A single item will make the form look a little
cleaner but if the list is short then it is faster for the end user to just
select from the list without scrolling or such.
 
W

WLMPilot

Thanks, it looks like I am going to use a combobox, but I do not want the
user to be able to add to the list via the combobox. How is that disabled?

Also, how do I populate the combobox? The way my data is set up for
Airports is that each Airport and its information takes a column, ie if four
airports are listed on the worksheet "Airports", the column C, D, E, and F
are used. This list will grow so I do not need a fixed endpoint, but a
floating endpoint. I am guessing something like xlRight. But I do not know
where to go from there. The data is located in
C1:F1, currently, but again it can grow to G1, H1, I1, etc.

Thanks,
Les
 
M

merjet

It's easier to populate a ComboBox when all the items
are in one column, but in one row is doable. To disable
allowing the user to add items, include the next-to-last
line below, or set it in the Properties Window.

Private Sub UserForm_Initialize()
Dim c1 As Range
Dim c2 As Range
Dim iCol As Integer

Set c1 = Sheets("Airports").Range("C1")
Set c2 = c1.End(xlToRight)
For iCol = 3 To c2.Column
ComboBox1.AddItem c1.Offset(0, iCol - 3).Value
Next iCol
ComboBox1.Style = fmStyleDropDownList
End Sub

Hth,
Merjet
 

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