[values from validation list]

K

Karol_tom

Hello,

I want use Userform where user can choose only values which are in
validation list for this cell.

How I can do it (get all values from validation list into listbox) ?
 
D

Dave Peterson

If the list for the cell is in a range, you could use that as the .rowsource
property. Or load the values into an array and use that.

For instance, I created a small userform with a combobox. And I named my
data|validation list myList (and it is on Sheet1).

This is the code behind the userform:

Option Explicit
Private Sub UserForm_Initialize()
With Me.ComboBox1
.Style = fmStyleDropDownList
.List = Worksheets("sheet1").Range("myList").Value
End With
End Sub

I could have used this, too:

Option Explicit
Private Sub UserForm_Initialize()
With Me.ComboBox1
.Style = fmStyleDropDownList
.RowSource = _
Worksheets("sheet1").Range("myList").Address(external:=True)
End With
End Sub
 

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