ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   List box Setup from Varying 1d Array (https://www.excelbanter.com/excel-programming/318945-list-box-setup-varying-1d-array.html)

Andrew Heath

List box Setup from Varying 1d Array
 
Hi

I need to create a listbox1 within a userform to select one name from a list
of names.

The list of names varies in length from 3 to 60 people.

The list of names starts at B2 and goes down (and varies in number)

Can I get it to default to the 'users' name (from ToolsOptions...General)?

Do I have to set up a dynamic 1d array when I call up the userform?

Kind regards

--
Andrew 'The Ox' Heath
Brisbane, QLD
Australia

Tom Ogilvy

List box Setup from Varying 1d Array
 
Private Sub Userform_Initialize()
Dim rng as Range
with worksheets("Data")
set rng = .Range(.Range("B2"),.Range("B2").End(xldown))
End with
Listbox1.RowSource = rng.Address(external:=True)
listbox1.Value = Application.UserName

End Sub

--
Regards,
Tom Ogilvy

"Andrew Heath" (delete) wrote in message
...
Hi

I need to create a listbox1 within a userform to select one name from a

list
of names.

The list of names varies in length from 3 to 60 people.

The list of names starts at B2 and goes down (and varies in number)

Can I get it to default to the 'users' name (from

ToolsOptions...General)?

Do I have to set up a dynamic 1d array when I call up the userform?

Kind regards

--
Andrew 'The Ox' Heath
Brisbane, QLD
Australia





All times are GMT +1. The time now is 02:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com