Combo box in Visual Basics

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Everyone,

I'm fairly new with Visual Basics.

I'm creating a form and I'd like to add a combo box (drop down Lisyt), and I
can't seem to figure out how to validate the list from there.

Does anyone know how or have a reference to this?

Thank you in advance.
 
Next time you're in the VBE working on your userform, click on the combobox and
hit F4 (to show its properties).

Then change the style to fmStyleDropDownList--this allows only the items in the
combobox's list.

Then you can use the .rowsource property to point at the range that should be
used for validation.

If you like you can do this in code, too:

Option Explicit
Private Sub UserForm_Initialize()

Me.ComboBox1.Style = fmStyleDropDownList

With Worksheets("sheet1")
Me.ComboBox1.RowSource = .Range("a2", _
.Cells(.Rows.Count, "A").End(xlUp)).Address(external:=True)
End With

End Sub

There are other ways that can be used to populate the combobox, too--if you're
doing something special.

Debra Dalgleish has a list of books at her site:
http://www.contextures.com/xlbooks.html

John Walkenbach's is a nice one to start with. I think that John Green (and
others) is nice, too (for a second book??). See if you can find them in your
local bookstore and you can choose what one you like best.
 

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

Back
Top