MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Creating ListBoxes


Posted by Leon on August 28, 2001 12:17 PM

New at VB for Excel. Is there an easy way to get a list that I defined as a name within Excel (the list is a one column list by about 200 rows) into the Listbox with the use of either Additem or some other function? The only way I could do this is to add each item within the list one by one via ListBox.Additem "xxx". Thanks in advance for the help.


Posted by Ivan F Moala on August 28, 2001 10:38 PM

To do this fas, you need to define you named
range as an array variant.

eg
Private Sub UserForm_Initialize()
Dim MyArray As Variant
'Where mylist is your named range
MyArray = Range("mylist")

ListBox1.List = MyArray
End Sub

Ivan