Populating UserForm.Listbox


Posted by Bob on October 25, 2001 10:09 AM

Is there a way to populate a ListBox with a selected range on a worksheet. I have the range That is needed. I just cant figure out how to populate the listbox.



Posted by Bob Umlas on October 25, 2001 11:35 AM

---------------------------------------------
Listbox in a Userform? On a sheet?
In Userform, you can change the initialize event of the form to have the Rowsource = Selection.Address:
Private Sub UserForm_Initialize()
Me.ListBox1.RowSource = Selection.Address
End Sub
On a sheet, if you're using a Forms listbox (as opposed to ActiveX), you can write code in the selectionChange event to populate it. Using ActiveX requires writing more involved code, but I don't think you're asking that.

HTH

Bob Umlas
Excel MVP